KMM (Kotlin Multiplatform Mobile)

Abhishek Srivastava
4 min readAug 10, 2022

--

For almost the last Six years in my career, I was working on mobile development for native apps (Android ) and Hybrid apps (Xamarin Native and Flutter). But I also heard about cross-platform platforms like React Native and one of the interesting things I found during my learning journey is Koltin Multiplatform Mobile (KMM), an SDK for cross-platform mobile development.

Let’s started with KMM and learn how we can integrate it…

What’s KMM?

KMM (Kotlin Multiplatform Mobile) is an SDK for cross-platform mobile development. With KMM, you can develop multiplatform mobile applications and share parts of your applications between Android and iOS, such as core layers, business logic, presentation logic, and more. What’s new in Kotlin for KMM can be found in the documentation and KMM roadmap.

KMM uses the multiplatform abilities of Kotlin and reduces time spent writing and maintaining the same code for different platforms while retaining the flexibility and benefits of native programming. And you can use iOS and Android features without any overhead.

Requirement analysis before start integrating

Prerequisites

  • Android Studio Bumblebee 2021.1.1 or higher.
  • JDK 11 or higher.
  • Kotlin Plugin for Android Studio, version 1.6.10 or higher.
  • An Android Virtual Device (AVD) using a supported CPU architecture.
  • Xcode -version 11.3 or higher
  • Xcode command line developer tool

Additionally, Kotlin Multiplatform projects require the following:

  • After install plugin, A KMM App created using the “KMM Application” template in Android Studio. Follow the instructions in the KMM documentation or see attached screenshot to create KMM application.

When you finish the project setup, You will see the project structure same as below attached screenshot.

We will discuss their structure letter.

Note: For iOS specific application development, you required mac

Supported Target Environments

Kotlin Multiplatform supports a wide range of application environments. The SDK supports the following environments:

  • android
  • iosArm64
  • iosSimulatorArm64
  • iosX64
  • jvm
  • macosArm64
  • macosX64

The SDK does not support the following environments:

  • androidNativeArm32
  • androidNativeArm64
  • androidNativeX86
  • androidNativeX64
  • iosArm32
  • js
  • linuxArm32Hfp
  • linuxArm64
  • linuxMips32
  • linuxMipsel32
  • linuxX64
  • mingwX64
  • mingwX86
  • tvosArm64
  • tvosSimulatorArm64
  • tvosX64
  • wasm32
  • watchosArm32
  • watchosArm64
  • watchosSimulatorArm64
  • watchosX86
  • watchosX64

Now let’s discuss about the project structure, Each Kotlin Mobile Multiplatform project includes three modules:

  • shared is a Kotlin module that contains the logic common for both Android and iOS applications — the code you share between platforms. It uses Gradle as the build system that helps you automate your build process. The shared module builds into an Android library and an iOS framework.
  • androidApp is a Kotlin module that builds into an Android application. It uses Gradle as the build system. The androidApp module depends on and uses the shared module as a regular Android library.
  • iOSApp is an Xcode project that builds into an iOS application. It depends on and uses the shared module as an iOS framework. The shared module can be used as a regular framework or as a CocoaPods dependency, based on what you’ve chosen in the previous step in iOS framework distribution. In this tutorial, it’s a regular framework dependency.

The shared module consists of three source sets: androidMain, commonMain, and iosMain. Source set is a Gradle concept for a number of files logically grouped together where each group has its own dependencies. In Kotlin Multiplatform, different source sets in a shared module can target different platforms.

For more detail, We will learn in part-2.

--

--

Abhishek Srivastava

Senior Software Engineer | Android | Java | Kotlin | Xamarin Native Android | Flutter | Go

Recommended from Medium

Lists

See more recommendations