Creating a simple Kotlin Multiplatform project based on moko-template

1. Intro

Tools

  • Android Studio 3.4.0+ (do not use 3.5.1 version, cause there is a bug is breaking MPP project);
  • Xcode 10.3+;
  • Xcode Command Line Tools (xcode-select --install);
  • CocoaPods (sudo gem install cocoapods);
  • JDK — требуется для запуска gradle из Xcode build phase.

The Result

2. Create the project based on moko-template

The project template already has preconfigured builds of iOS and Andoroid application with shared library and you will save the time to integrate shared library to iOS project on iOS platform, to configure Kotlin Multiplatform modules and dependencies (using mobile-multiplatform-gradle-plugin you can make configuraion is simplier).
The project template has a sample of several features as well as.

Use this template

After succefull creation you should clone this rep: git clone <git url of repo>.

3. Test build

  • on Android: open root repository directory in Android Studio, wait while Gradle Sync will finish, and run android-app as regular application.
  • on iOS: install project’s CocoaPods (in directory ios-app run a command pod install, and after this open ios-app/ios-app.xcworkspace in Xcode and press Run for running application.

Building of Kotlin/Native can take a time (it will start automatically on doing pod install as well as building iOS project).

4. Setting up an application identifiers

Change Appliсation Id

android {
...

defaultConfig {
...

applicationId = "dev.icerock.codelab.giphy"
...
}
}

iOS - you have to set Bundle Identifier in the project's setting in Xcode like on the screenshot below:

Change an application name

<resources>
<string name="app_name">Giphy App</string>
...
</resources>

iOS - you have to set Display name in the project's setting in Xcode like on the screenshot below:

Change an application icon

To change Android icons you have to move content of android directory of this archive in android-app/src/main/res directory. After this, you need to set this icon on android-app/src/main/AndroidManifest.xml:

<manifest>
<application
...
android:icon="@mipmap/ic_launcher">
...
</application>
</manifest>

To change icons on iOS you have to replace ios-app/src/Assets.xcassets/AppIcon.appiconset directory by the archive's version.

Change launch screen

5. Next steps

--

--

A boundlessly imaginative mobile development team from the depths of Siberia and its capital, the city of Novosibirsk. Let’s meet on www.icerockdev.com

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store