Skip to main content

Native Mobile to Kotlin Multiplatform Blueprint

Share business logic across iOS and Android with Kotlin Multiplatform while keeping SwiftUI and Compose UIs native. Extract domain, networking, and persistence into a shared module, distributed as an XCFramework.

From
Native Mobile
To
Kotlin Multiplatform
Difficulty
Advanced
Duration
22 weeks
Team Size
medium

What and Why

Kotlin Multiplatform (KMP) shares business logic, networking, and data layers across platforms while leaving the UI native: SwiftUI on iOS and Jetpack Compose on Android. This contrasts with React Native and Flutter, which also share UI. KMP suits teams that want a single source of truth for domain logic but refuse to compromise on native UX. Compose Multiplatform can optionally share UI later.

Phases

Assessment. Identify duplicated logic across the iOS and Android codebases: models, validation, networking, caching, and use cases. Confirm native UI stays. Evaluate KMP library maturity for your needs (Ktor, SQLDelight, kotlinx.serialization, coroutines).

Shared module setup. Create the shared KMP module with commonMain plus androidMain/iosMain source sets. Wire Gradle and produce an XCFramework for iOS consumption. Set up dependency injection (Koin) and serialization.

Logic extraction. Move domain models, repositories, networking (Ktor), and persistence (SQLDelight) into commonMain, applying hexagonal boundaries so platform code depends on interfaces. Migrate incrementally, one feature at a time, keeping native fallbacks.

iOS integration. Consume the shared XCFramework from Swift. Bridge coroutines/Flows to Swift async/Combine. Keep SwiftUI views thin, calling shared use cases.

Rollout. Expand shared coverage feature by feature. Native UIs remain; only logic consolidates. Establish a single test suite for shared code.

Key Risks and Mitigations

  • Tooling maturity: iOS interop and build tooling evolve; pin versions and follow JetBrains guidance.
  • Skills gap: iOS engineers must read Kotlin; provide Swift-friendly wrappers (KMP-NativeCoroutines).
  • Platform parity: Validate concurrency and serialization behavior on both platforms.

Recommended Tooling

Kotlin Multiplatform, Ktor, SQLDelight, kotlinx.serialization, coroutines/Flow, Koin, and XCFramework distribution. Test shared logic with the Kotlin test framework.

Success Metrics

High business-logic code reuse, reduced duplicate-bug rate across platforms, faster lead time for logic changes, and unchanged native UX quality.

Prerequisites

Gradle proficiency, two existing native apps, and agreement that UI remains native. Start with a low-risk feature to prove the pipeline.