Presented at Cocoa勉強会関西64 #cocoa_kansai
iOSΞϓϦΤϯδχΞͷͨΊͷ AndroidΞϓϦ։ൃ
View Slide
cockscomb
Hiroki Kato
iOS Android
։ൃڥXcodeiOS SimulatorApp StoreAndroid StudioEmulatorGoogle PlayOSSiOS Android
ϓϥοτϑΥʔϜMac (OS X)iPhone/iPad (iOS)Car PlayApple Watch (watchOS)Apple TV (tvOS)Phone/TabletAndroid WearAndroid TVAndroid AutoiOS Android
։ൃݴޠSwiftObjective-CJava(Kotlin)iOS Android
ϏϧυxcodebuildґଘཧCocoaPodsCarthagegradleiOS Android
gradle• Ϗϧυπʔϧ• build.gradleϑΝΠϧ• Android Studio͕αϙʔτ• ίϚϯυϥΠϯ͔Βར༻Ͱ͖ΔAndroid
όʔδϣχϯάiOS 9iOS 8Earlier6.0 (Marshmallow)5.1 (Lollipop)5.0 (Lollipop)4.4 (Kitkat)4.3 (Jelly Bean)4.2 (Jelly Bean)4.1 (Jelly Bean)4.0 (Ice Cream Sandwich)Android
API LevelVersion Version Code API Level6.0 MARSHMALLOW 235.1 LOLLIPOP_MR1 225.0 LOLLIPOP 214.4W KITKAT_WATCH 204.4 KITKAT 194.3 JELLY_BEAN_MR2 184.2 JELLY_BEAN_MR1 174.1 JELLY_BEAN 164.0.3, 4.0.4 ICE_CREAM_SANDWICH_MR1 154.0, 4.0.1, 4.0.2 ICE_CREAM_SANDWICH 14Android
FragmentationEarlier9%iOS 824%iOS 967%Earlier4.0%Ice Cream Sandwich3.3%Jelly Bean29.0%Kitkat37.8%Lollipop25.6%Marshmallow0.3%iOS Android
Fragmentation• Support Library• ࠷৽ػೳͷόοΫϙʔτ• Google Play Services• OSͱಠཱͨ͠APIAndroid
ΞϓϦͷೖޱUIApplicationMainStoryboardAndroidManifest.xmliOS Android
AndroidManifestxmlns:android="http://schemas.android.com/apk/res/android"> android:icon="@mipmap/ic_launcher" android:label="@string/app_name" android:theme="@style/AppTheme"> android:name=".MainActivity" android:label="@string/app_name" android:theme="@style/AppTheme.NoActionBar"> android:name="android.intent.category.LAUNCHER"/> Android
ը໘ͷߏ୯ҐUIViewControllerActivityFragmentiOS Android
Activity/Fragment• Activity• ը໘ʹͻͱ͚ͭͩ• Fragment• ActivityʹแͰ͖ΔAndroid
ϥΠϑαΠΫϧUIViewControllerinitviewDidLoadviewWillAppearviewDidAppearviewWillDisappearviewDidDisappeardeinitActivityonCreateonStartonRestoreInstanceStateonResumeonPauseonSaveInstanceStateonStoponDestroyiOS Android
Activityͷ࠶ੜ• Activity࠶ੜ͞ΕΔ• ը໘ͷճసͳͲͷมԽʹىҼ• ঢ়ଶΛࣦΘͳ͍Α͏ʹ࡞Δ• onSaveInstanceState• ParcelableAndroid
ը໘ભҠshowViewControllerUIStoryboardSegueIntentFragmentTransactioniOS Android
Intent• ৽͍͠ActivityΛελʔτͰ͖Δ• γϦΞϥΠζՄೳͳύϥϝʔλ• ଞͷΞϓϦͷActivityελʔτ• ҉తͳIntentAndroid
IntentIntent intent = new Intent(this, MainActivity.class); intent.putExtra("extra_name_key", "cockscomb"); startActivity(intent);Intent intent = new Intent(Intent.ACTION_VIEW, Uri.parse("http://example.com")); startActivity(intent);Android
ϏϡʔUIViewViewViewGroupiOS Android
View/ViewGroup• View• ViewGroup• ViewΛแͰ͖Δ• แͨ͠ViewΛϨΠΞτ͢ΔAndroid
༷ʑͳϏϡʔUIView ViewUILabel/UITextView TextViewUITextField/UITextView EditTextUIImageView ImageViewUIButton Button/ImageButtonUIScrollView ScrollViewUITableView/UICollectionView RecyclerViewUIWebView/WKWebView WebViewiOS Android
ϨΠΞτϑΝΠϧStoryboardNib (Xib)Layout XMLiOS Android
Layout XMLxmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical"> android:id="@+id/user_name" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="text"/> android:id="@+id/password" android:layout_width="match_parent" android:layout_height="wrap_content" android:inputType="textPassword"/> android:id="@+id/login_button" android:text="@string/action_sign_in" android:layout_width="match_parent" android:layout_height="wrap_content"/> Android
ϏϡʔͱͷଓTarget Action@IBAction@IBOutletandroid:idOnClickListenerData BindingiOS Android
Data Binding Libraryxmlns:android="http://schemas.android.com/apk/res/android"> android:orientation="vertical" android:layout_width="match_parent" android:layout_height="match_parent"> android:layout_height="wrap_content" android:text="@{user.firstName}"/> android:layout_height="wrap_content" android:text="@{user.lastName}"/> Android
ϨΠΞτͷํ๏Auto LayoutResizing MaskViewGroupiOS Android
ViewGroup• FrameLayout• LinearLayout• RelativeLayout• GridLayoutAndroid
αΠζຖͷ࠷దԽSize ClassDisplay ScaleUser Interface Idiom໋໊نଇը໘ີີඇґଘϐΫηϧiOS Android
Ϧιʔεͷ໋໊نଇ• res/layout/login.xml• σϑΥϧτ• res/layout-sw800dp/login.xml• ը໘෯͕800dpҎ্• R.layout.loginAndroid
ը໘ີ• xxxhdpi — 4.0• xxhdpi — 3.0• xhdpi — 2.0• hdpi — 1.5• mdpi — 1.0• ldpi — 0.75Android
୯Ґ• dp (ີඇґଘϐΫηϧ)• 160dpi• sp (εέʔϧඇґଘϐΫηϧ)• ઃఆ͞ΕͨςΩεταΠζʹൺྫAndroid
༷ʑͳϦιʔεAsset CatalogStringsetc.DrawableR.drawable.ic_hamburgerValuesR.color.darkTextColorR.string.loginetc.iOS Android
Ϧιʔε• XMLPNG• छྨຖͷσΟϨΫτϦʹஔ͘• ϨΠΞτ/ը૾/৭/αΠζ/Ξχϝʔγϣϯ/ελΠϧ/จࣈྻ/ϝχϡʔ• R.xxx.yyyAndroid
Drawable• BitmapDrawable• RoundedBitmapDrawable• NinePatchDrawable• ShapeDrawable• VectorDrawable• AnimatedVectorDrawable• ColorDrawable• GradientDrawable• LayerDrawable• RippleDrawable• LevelListDrawable• StateListDrawable• AnimationDrawable• ClipDrawable• InsetDrawable• RotateDrawable• ScaleDrawable• PictureDrawableAndroid
ϑΝΠϧΞΫηεNSFileManager ContextiOS Android
Context• ΞϓϦͱ֎෦ڥΛܨ͙• Ϧιʔεͷऔಘ/ϑΝΠϧΞΫηε• Application/Activity/ServiceAndroid
Service• ը໘ͱಠཱͨ͠ॲཧ• όοΫάϥϯυͰಈ࡞Ͱ͖Δ• IntentServiceAndroid
ετϨʔδFile SystemCore DataSQLiteKeychainInternal StorageExternal StorageSQLiteAccountManagerKey StoreiOS Android
ݖݶPHPhotoLibrary .requestAuthorization(_:)ύʔϛογϣϯiOS Android
ύʔϛογϣϯ• android:name="android.permission.INTERNET" />• Runtime PermissionsAndroid
ڞ༗URL SchemeOpen InDocument ProviderExtensionIntentFile SystemContent ProvideriOS Android
ςετXCTestUnit TestingUI TestingTesting Support LibraryAndroidJUnitRunnerEspressoUI AutomatoriOS Android