KMM (Kotlin Multiplatform Mobile)
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…
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
- 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:
- Kotlin Multiplatform Mobile (KMM) Plugin for Android Studio, version 0.3.1 or higher. (To see plugin detail see attached screenshot to download)
- 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:
The SDK does not support the following environments:
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:
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.
For more detail, You can follow the below links.
Getting started with Kotlin Multiplatform Mobile (KMM) | Bitrise
For almost the last three years in my career, I was working on mobile testing and started learning more about mobile…