Kotlin Multiplatform Mobile(KMM) is an SDK that allows you to use a language that you love so much and share the Kotlin code across multiple targets. The first alpha version was released at the end of summer 2020, and I believe that we will see much more soon.

Let’s take this opportunity and share common code between Android and iOS platforms. The previous story explores SwiftUI and Jetpack Compose to build simple Android and iOS applications that display a list of mocked movies. So, we will reuse existing projects, create a shared KMM module, place common code there, and configure projects to work with it.

Before we start

Make sure that you correctly configured the working machine for KMM. You can find detailed interactions in the official documentation here.

Identify code for sharing

The most common choice is to share business logic aka domain layer. Currently, the KMM community has a lot of libraries that allow us to share even more than that. We can share the logic of network communicationscaching information, and even the UI layer. In any case, sharing codebase brings some difficulty especially for iOS developers, because they will depend on a generated framework with common code.

Before you make your own decision I recommend going through these case studies. You can find a huge number of well-known companies that are using this technique right now and sharing their experience.

In our case, we will move common business logic to the KMM module and reuse it from Android and iOS applications.

#kotlin #swift #swift-programming #kotlin-multiplatform

Integrate Kotlin Multiplatform Mobile to Existing android and IOS Apps
2.10 GEEK