Skip to content
Commitwise
Menu

When would you use Kotlin Multiplatform, and what makes it work well for the iOS team?

AndroidSenior

In shortShare logic that must be identical on both platforms (rules, networking, storage, sync) and keep UI and platform integrations native. Make the exported API Swift-friendly: declared exceptions, adapters for Flows and sealed classes (SKIE), small facades, and a build integration iOS developers can live with.

Model answer

What to share: code that must behave identically: domain models and rules, repositories, networking with Ktor, storage with SQLDelight or Room KMP, sync and caching, sometimes presentation state. Keep UI native (or adopt Compose Multiplatform deliberately), and keep integrations like health data, payments and push native.

How: commonMain with multiplatform libraries (coroutines, serialization, datetime); expect/actual for small primitives; interfaces implemented by each app for bigger capabilities, which keeps common code testable; tests in commonTest run on every target.

Swift interop: Swift sees Kotlin through Objective-C. Suspend functions become async, but only exceptions declared with @Throws become Swift errors; undeclared ones crash the app. Flows need adapters (SKIE, KMP-NativeCoroutines or callback wrappers); sealed classes aren’t exhaustive in Swift without SKIE. Export small facades with clear names.

Adoption: start with one valuable module (a rules engine, sync), with owners from both platforms; integrate through the Gradle build phase in a monorepo or an XCFramework via SPM; budget for Kotlin/Native build time and a few MB of binary size; measure cross-platform bug counts and time to ship rules on both platforms.

What they're looking for

Judgment about what to share, expect/actual vs interfaces, multiplatform libraries, Swift interop pitfalls (exceptions, Flows, sealed classes), and adoption concerns (ownership, build time, binary size, distribution).

Common mistakes

  • Sharing UI and platform integrations first.
  • Exporting suspend functions without @Throws.
  • Treating it as an Android-team-only project.

More android questions

Esc

Type to search the whole site.