Kotlin Multiplatform (KMP) has matured from an experimental sharing layer into a mainstream production architecture. With official KMP support in Room, DataStore, Ktor, and Compose Multiplatform, teams can share as little or as much as makes sense for their product.

The Golden Rule: Share the Core First

The lowest-risk way to adopt KMP is sharing your data and domain layers while keeping platform-native entry points:

  • Networking: Ktor Client with kotlinx.serialization
  • Local persistence: Room KMP + DataStore
  • Concurrency: Kotlin Coroutines & Flow
  • DI: Koin or Metro / kotlin-inject

Clean commonMain Repository Pattern

Keep platform-specific engines (OkHttp on Android, Darwin on iOS) injected behind a shared HttpClient factory:

kotlin
// commonMain
class FeedRepository(
    private val api: FeedApi,
    private val dao: ArticleDao
) {
    fun observeFeed(): Flow<List<Article>> = dao.observeAll()

    suspend fun refreshFeed(): Result<Unit> = runCatching {
        val remote = api.fetchLatest()
        dao.upsertAll(remote.map { it.toEntity() })
    }
}

Exposing Flow Cleanly to Swift

While Kotlin Flow works directly in Android Compose via collectAsStateWithLifecycle(), iOS Swift callers benefit from SKIE (Swift Kotlin Interface Enhancer) or a thin wrapper that turns Flow<T> into AsyncSequence:

swift
// iOS SwiftUI ViewModel
for await articles in repository.observeFeed() {
    self.articles = articles
}

When to Add Compose Multiplatform for UI

Consider sharing UI with Compose Multiplatform when:

  1. Your app has custom brand design rather than strict iOS Cupertino chrome.
  2. A single mobile team ships features simultaneously to Android and iOS.
  3. You want shared UI previews, theming, and navigation logic.

If your app relies heavily on Apple-specific frameworks (ARKit, complex Share Extensions, or native MapKit sheets), keep SwiftUI at the outer shell and embed shared Compose Multiplatform screens only where they shine.