Kotlin Multiplatform starter guide
Where to start
Learn about Kotlin Multiplatform (KMP) and Compose Multiplatform (CMP): What they are, their advantages and use cases.
Try KMP out on a sample project to see how it's organized and how it runs on different platforms.
Learn KMP basics
The basics include:
Understand how a KMP / CMP project is organized. This covers:
Common and platform-specific code in a shared module.
Targeted platform declarations.
Adding a dependency to a KMP project.
For a practical example of multiplatform and platform-specific dependency organization, see our sample.
The tutorial that leads to the final state of that sample is available in the documentation.
If you are already familiar with KMP, make sure you're up to date with the recommended project structure for an average project. It takes into account how the release of Android Gradle plugin 9.0 affected the requirements for a KMP project and covers:
Module structure (independent app modules with shared code modules used as libraries).
Creating new app modules and transitioning from an older structure used with AGP 8.
Suggested video on project structure recorded by a JetBrains developer advocate.
Share code
There are different ways to share code in a KMP project, with some platform specifics:
The basic examples of calling common code from app modules are covered in onboarding tutorials:
How to access platform-specific APIs:
Use multiplatform libraries when possible.
Use the
expect/actualmechanism when no suitable multiplatform library is available.
While calling shared Kotlin from Android Kotlin is relatively straightforward, iOS interoperability takes some getting to know it:
Learn how to integrate your shared code with the iOS app (all samples referenced in this doc have examples of iOS integration set up).
Check out the sample and tutorial that includes making Kotlin coroutines work with iOS.
See the guide on using existing SPM packages in your KMP iOS app.
Read the in-depth explanation of calling Swift / ObjC from Kotlin and vice versa.
Learn about the more straightforward Swift export approach (currently in Alpha).
In general, the less interop, the better, so for a smoother experience we recommend relying on Compose Multiplatform to build the bulk of your UI for all platforms.
Discover the ecosystem
A comprehensive catalog of multiplatform libraries is available at klibs.io:
Most popular cases are already covered with robust solutions, usually with available alternatives: SQLDelight and Room for databases, Ktor and OkHttp for networking, Coil for image loading, and so on.
App samples built to use multiplatform libraries for most popular use cases are available:
SQLDelight / Ktor / kotlinx-serialization / Koin with the corresponding tutorial.
The multiplatform Jetcaster app converted from the original Android sample.
Create a KMP library
If you decide to create apps which share code by using a multiplatform library, check out these documentation pages:
Tutorials on publishing artifacts to Maven Central and npm
Publish the artifacts
Read the general article on publishing KMP apps.
Don't forget about the privacy manifest required by the Apple App Store.
Learning resources catalog
All of the mentioned resources, along with more in-depth guides and third-party content, are catalogued on the Learning resources page.