Kotlin Multiplatform

This content was generated with the assistance of AI and should be verified against the official Kotlin Multiplatform documentation before being relied on in production.

See the section bibliography for the reference material consulted while preparing these pages.

Welcome to the Kotlin Multiplatform reference. Kotlin Multiplatform (KMP) is JetBrains' technology for compiling one Kotlin codebase to several platforms — JVM and Android, native iOS and macOS binaries, JavaScript and WebAssembly — while still letting each platform keep its own code where it matters. You decide how much to share: only the business logic (networking, storage, domain rules and view models) behind fully native UIs written in Jetpack Compose and SwiftUI, or the user interface as well with Compose Multiplatform (CMP), JetBrains' port of Jetpack Compose to Android, iOS, desktop and the web. Both paths are documented in full here, on top of the same project.

This section targets Kotlin 2.4.20 and Compose Multiplatform 1.12.1 (based on Jetpack Compose 1.12.1), the Android Gradle Plugin 9.4 with its com.android.kotlin.multiplatform.library plugin, and Xcode 26.4, the version Kotlin 2.4.20 is tested against. Every page names the exact library versions it uses — Ktor 3.6.0, SQLDelight 2.4.0, Koin 4.2.2, Room 3 (androidx.room3) 3.0.3, SKIE 0.10.15, KMP-NativeCoroutines 1.0.6, Mokkery 3.5.0 and the rest — and states the stability level of every API that is not Stable. In particular, Swift export and SwiftPM import are Alpha, and Kotlin/Wasm and Compose Multiplatform for web are Beta, while Android, iOS, desktop and Kotlin/JS targets are Stable.

This section does not re-teach the Kotlin language, Jetpack Compose basics or SwiftUI basics — it links to them. The Kotlin language lives in the Kotlin Reference. The sibling sections are Android (native Android and Jetpack Compose), Apple Platforms (Swift, SwiftUI, Xcode and the App Store) and React Native (the TypeScript cross-platform alternative). The multi-platform projects page of the Apple section describes Apple’s own multi-platform targets and is unrelated to Kotlin Multiplatform.

How Kotlin Multiplatform got here

Year What changed

2017—​2018

Kotlin/Native entered preview and Kotlin gained multiplatform projects, sharing code between the JVM, JavaScript and native targets through expect/actual declarations.

2020

Kotlin Multiplatform Mobile (KMM) reached Alpha: Android and iOS apps sharing a Kotlin module, with a dedicated IDE plugin.

2021

Compose for Desktop and Compose for Web appeared as previews, the first steps toward sharing UI code beyond Android.

2022

The new Kotlin/Native memory manager (default since Kotlin 1.7.20) removed the object-freezing restrictions that had made concurrent iOS code awkward.

2023

Kotlin Multiplatform became Stable with Kotlin 1.9.20, together with the default hierarchy template.

2024

Google announced official support for Kotlin Multiplatform for shared business logic on Android, and Jetpack libraries (ViewModel, Room, DataStore, Paging) began to ship multiplatform artifacts. Kotlin 2.0 made the K2 compiler the default.

2025

Compose Multiplatform for iOS became Stable. Kotlin/Wasm and Compose Multiplatform for web reached Beta.

2026

The com.android.kotlin.multiplatform.library plugin became the Android target under AGP 9, which no longer allows com.android.application or com.android.library next to the KMP plugin. Swift export reached Alpha, as did SwiftPM import, steering iOS integration away from CocoaPods.

New here? Read in this order

Pick the path that matches your goal. The numbered lists follow the order of the pages in the navigation.

Share logic, keep native UI — the path for teams that want SwiftUI on iOS and Jetpack Compose on Android:

Share the UI with Compose Multiplatform — one UI for Android, iOS, desktop and the web:

Add KMP to an existing app — migrate an Android app, or add a shared module to an iOS app, step by step:

The TrailMate Everywhere project

Every code example is a slice of one project: the Android section’s TrailMate hiking-trail app (package com.example.trailmate) made multiplatform, so pages can link to the Android equivalents instead of repeating them.

  • Modules — sharedLogic (domain, data and view models), sharedUI (the Compose Multiplatform TrailListScreen, TrailDetailScreen, SettingsScreen, App() and TrailMateTheme), androidApp, iosApp (an Xcode project with a SwiftUI version and a Compose Multiplatform MainViewController version), desktopApp and webApp (wasmJs).

  • Domain and data — Trail(id, name, region, lengthKm, difficulty, photoUrl, isFavorite), enum class Difficulty, TrailPhoto; the remote API at https://api.example.com/v1/ through the Ktor TrailApiClient and TrailDto; a SQLDelight TrailMateDatabase with Room 3 as the alternative; a DataStore UserPreferencesRepository; the TrailRepository interface implemented by OfflineFirstTrailRepository; expect/actual platformName() and currentTimeZone(); and the LocationProvider interface with AndroidLocationProvider and IosLocationProvider.

  • Presentation — TrailListViewModel and TrailDetailViewModel exposing StateFlow<TrailListUiState>, wired through the Koin module trailMateModule.

  • Two UI paths — native UI (a SwiftUI TrailListView observing the shared view model through SKIE or KMP-NativeCoroutines, and Jetpack Compose on Android) and shared UI (Compose Multiplatform everywhere, with an MKMapView embedded on iOS).

  • Tests — OfflineFirstTrailRepositoryTest, FakeTrailApiClient (Ktor MockEngine), TrailListViewModelTest (Turbine) and TrailListScreenTest (runComposeUiTest).

  • Library example — the publishing and CI pages use a small library, com.example:trail-geo (geodesic distance and elevation-profile helpers), published to Maven Central and as an XCFramework through SwiftPM.

What’s covered

Foundations

Sharing business logic

iOS integration and interop

Sharing UI with Compose Multiplatform

Quality, shipping and adoption

Reference

Book and official sources compared

One book was read locally against the concepts documented here, purely to decide what to cover and to check for gaps — it is not quoted or copied into this repository, and no other page of this section cites it. The official documentation is the primary source for every page.

# Book Publisher / year / ISBN Publisher page

B1

Róbert Nagy, Simplifying Application Development with Kotlin Multiplatform Mobile: Write robust native applications for iOS and Android efficiently

Packt, March 2022, ISBN 978-1-80181-258-0

Packt

The book’s example app, Dogify (Dog API, Ktor, SQLDelight, Koin, Jetpack Compose on Android and SwiftUI with Combine on iOS), matches the "share logic only" path documented in pages 9 to 19.

Concept by book matrix

A check mark means the topic has a chapter or a main section, a half mark means partial coverage or an older API, and a dash means it is not covered. The page numbers are the position of the page in the navigation.

Concept group (pages) Official B1 (chapter)

Native vs cross-platform vs multiplatform; use cases (1)

✔

✔ (Ch 1)

The Kotlin compilers: JVM, Native, JS, Wasm (2)

✔

◐ (Ch 2; no Wasm, JS as ES5 only)

Tooling, IDE, wizard (3)

✔

◐ (Ch 4; Android Studio Arctic Fox, KMM plugin, AppCode)

Project structure, source sets, hierarchy (4)

✔

◐ (Ch 2 Commonizer, Ch 5; ios() shortcut)

Gradle DSL, version catalogs, compatibility (5)

✔

◐ (Ch 3 Gradle intro; buildSrc Versions object)

Android target and AGP 9 (6)

✔

 — 

expect/actual and platform APIs (7)

✔

✔ (Ch 1, 5)

Dependencies, klibs.io, cinterop, SwiftPM import (8)

✔

◐ (CocoaPods only)

Kotlin for Swift developers (9)

◐

✔ (Ch 3)

Coroutines, Flow and concurrency (10)

✔

◐ (Ch 3, 8; native-mt coroutines, freezing)

Architecture and shared ViewModels (11)

✔

◐ (Ch 4, 8; no Jetpack ViewModel KMP)

Networking with Ktor (12)

✔

◐ (Ch 5; Ktor 1.x)

Local storage: SQLDelight, Room, DataStore (13)

✔

◐ (Ch 5; SQLDelight 1.x only)

Dependency injection (14)

◐

◐ (Koin 3.1 used; Kodein mentioned)

Essential multiplatform libraries (15)

✔

◐ (kotlinx.serialization; moko-resources mentioned)

iOS integration options (16)

✔

◐ (Ch 7, 9; embedAndSign, CocoaPods, XCFramework, SPM mentioned)

Objective-C/Swift interop and Swift export (17)

✔

◐ (Ch 2, 8; "direct Swift interop" as future work)

Coroutines and Flow from Swift (18)

✔

✔ (Ch 7; KMP-NativeCoroutines with Combine)

Kotlin/Native memory, performance and binary size (19)

✔

◐ (Ch 2, 8; old model, app size)

Compose Multiplatform fundamentals (20)

✔

 — (Ch 10 lists "shared UI" as future work)

CMP resources (21)

✔

◐ (moko-resources mentioned)

CMP navigation and lifecycle (22)

✔

 — 

CMP UI, Material 3, adaptive, accessibility (23)

✔

 — 

CMP on iOS: UIKit/SwiftUI interop (24)

✔

 — 

CMP desktop (25)

✔

 — 

Web: Kotlin/Wasm and Kotlin/JS (26)

✔

◐ (Ch 2; Kotlin/JS only)

Testing (27)

✔

◐ (Ch 8; test-common/test-annotations-common, fakes over mocks)

Publishing libraries (28)

✔

◐ (Ch 9; XCFramework, CocoaPods/Carthage/SPM)

Publishing apps (29)

✔

 — 

CI/CD with GitHub Actions (30)

✔

 — 

Adopting KMP: monorepo vs multi-repo, teams (31)

✔

✔ (Ch 9)

Concepts found mostly in the book

Each of these is folded into an existing page; none gets a page of its own.

Concept Where it is covered

The economics of native, cross-platform and multiplatform development: synchronization cost, and the assumed versus actual cost of cross-platform

What Kotlin Multiplatform Is and When to Use It

A Swift to Kotlin concept mapping (optionals, structs versus data classes, copy-on-write, extensions, async/await versus coroutines, Combine versus Flow)

Kotlin for Swift Developers

DTOs at the Swift boundary, and exposing callbacks from shared view models

Architecture, Shared ViewModels and State and Objective-C Interop, Swift Export and SKIE

Binary size of the Objective-C header, and limiting the exported API

Objective-C Interop, Swift Export and SKIE and Kotlin/Native Memory, Performance, Binary Size and Debugging

Fakes over mocks on Kotlin/Native

Testing Multiplatform Code

Mono repository versus multiple repositories, team structure and adoption tips

Adopting KMP in Existing Android and iOS Apps

Official concepts missing from the book

These are documented from the official sources only: Compose Multiplatform on every platform (resources, navigation including Navigation 3, lifecycle and ViewModel, UIKit and SwiftUI interop, desktop and web); Compose Hot Reload; the default hierarchy template and the androidApp/sharedLogic/sharedUI layout; the AGP 9 Android-KMP plugin; the Jetpack KMP libraries (ViewModel, Room 3, DataStore, SQLite drivers, Paging); Swift export, SwiftPM import, the CocoaPods to SwiftPM migration and SKIE; the new memory manager and the CMS garbage collector; Kotlin/Wasm; target tiers and Apple minimum OS versions; klibs.io; ABI validation in the Kotlin Gradle plugin; Dokka 2; the Maven Central Portal with the vanniktech plugin; the App Store privacy manifest; GitHub Actions and TeamCity CI; the Kotlin Toolchain (formerly Amper); and the K2 compiler.

Outdated book material

These techniques appear in the section only as legacy, each next to its modern replacement.

Legacy technique (book, 2022) Modern replacement

"KMM" naming, the KMM Android Studio plugin, AppCode

"KMP"; the Kotlin Multiplatform IDE plugin for IntelliJ IDEA and Android Studio (AppCode is discontinued)

ios() target shortcut, iosX64 simulator target

Explicit iosArm64() and iosSimulatorArm64() with the default hierarchy template (ios() was removed in 2.2.0; iosX64 is Tier 3)

Manual iosMain dependsOn and the Commonizer explained by hand

The default hierarchy template (Kotlin 1.9.20)

Legacy memory model, freeze(), native-mt coroutines

The new memory manager (default in 1.7.20; the legacy one was removed in 1.9.20) and plain kotlinx-coroutines

buildSrc Versions object, kotlin("test-common") and test-annotations-common

Version catalogs (libs.versions.toml); kotlin("test") in commonTest

kotlin-android and com.android.library inside the shared module

com.android.kotlin.multiplatform.library, with a separate androidApp module (AGP 9)

Ktor 1.x (ktor-client-json, ktor-client-serialization, ktor-client-ios)

Ktor 3.x (ContentNegotiation with ktor-serialization-kotlinx-json, and ktor-client-darwin)

SQLDelight 1.x (com.squareup.sqldelight)

SQLDelight 2.x (app.cash.sqldelight), or Room 3 KMP

Koin 3.1

Koin 4.2 (koin-compose-viewmodel)

Fat or universal frameworks, bitcode

XCFrameworks (bitcode is unsupported since Kotlin 2.0.20)

CocoaPods-first iOS integration

Direct integration (embedAndSignAppleFrameworkForXcode) or SwiftPM export

"Direct Swift interop" as a future plan

Swift export (Alpha)

"Shared UI" as a future plan

Compose Multiplatform (Stable on iOS)

Kotlin/JS targeting ES5

Kotlin/JS with ES2015+ output, and Kotlin/Wasm

kapt-style annotation processing on Native

KSP (kspAndroid, kspIosArm64, and so on)

This section builds on material documented elsewhere on this site rather than repeating it. The Kotlin Reference covers the language every example is written in, including coroutines and flows. Android documents native Android, Jetpack Compose, Room, Ktor, Koin and Google Play — the TrailMate app that this section makes multiplatform. Apple Platforms covers Swift, SwiftUI, Xcode, Swift Package Manager, signing and the App Store for the iOS side. React Native is the cross-platform alternative that targets Android and iOS from one TypeScript codebase, and Git & GitHub underlies the version control and pull-request workflow assumed on the CI/CD page.

Bibliography

Kotlin Multiplatform documentation (kotlinlang.org)

Every kotlinlang.org/docs/multiplatform/ page cited on a concept page, grouped by topic. The official documentation is the primary source for every page and every code example.

Kotlin/Native, Kotlin/Wasm, Kotlin/JS, Gradle and API guidelines

The kotlinlang.org/docs/ and API reference pages cited on the concept pages, including the Kotlin language pages the sections link to instead of re-teaching.

Compose Multiplatform

The Compose Multiplatform documentation pages, the product page and the GitHub releases and repository.

Android Developers

The developer.android.com pages cited on the concept pages: the /kotlin/multiplatform/* articles, AGP 9, and the Jetpack release notes.

Third-party libraries

Official documentation or repository of every library the pages use.

Book