Share business logic — networking, persistence, validation — across Android, iOS, web, and desktop. Keep the UI native (SwiftUI on iOS, Compose on Android) where it matters most.
← Back to Client Side// commonMain — shared business logic class ProductRepository(private val client: HttpClient) { suspend fun fetchProducts(): List<Product> = client.get("https://api.example.com/products").body() } // commonMain — shared models @Serializable data class Product(val id: String, val name: String, val price: Double) // expect / actual — platform-specific glue expect class Logger() { fun log(message: String) } // androidMain actual class Logger { actual fun log(message: String) = Log.d("App", message) } // iosMain actual class Logger { actual fun log(message: String) = NSLog(message) }
A KMP module declares targets (androidTarget(), iosX64(), iosArm64(), jvm(), js()) and source sets (commonMain, androidMain, iosMain). Code is shared by default; platform-specific code lives in its own folder.
Kotlin/Native compiles a shared.framework that Swift imports like any Apple framework. Suspend functions are exposed as completion-handler callbacks (or modern Swift async via SKIE / KMP-NativeCoroutines).
JetBrains' UI framework on top of KMP — share Compose UI between Android, iOS, desktop, and web (Wasm). The most ambitious cross-platform UI story in the JVM world.
| Library | Purpose |
|---|---|
| Ktor Client | Multiplatform HTTP client. |
| SQLDelight | Type-safe SQL across platforms. |
| kotlinx.serialization | JSON / ProtoBuf serialization. |
| kotlinx.coroutines | Async & flows on every target. |
| Koin | Multiplatform DI. |
| SKIE | Better Swift interop (async/await, sealed classes). |
Banking, fitness, e-commerce — share rules & networking; keep UI native.
Kotlin shop adding iOS without learning React Native or Flutter.
Ship one Kotlin codebase; consumers get a native SDK on each platform.
Share UI across Android + iOS + desktop with Compose Multiplatform.