Your org wants to share code between an Android and an iOS app with Kotlin Multiplatform. How do you decide what belongs in the shared module versus staying native, and how do you handle platform-specific APIs?

technical-conceptual · Senior level · software-engineering

What the interviewer is really asking

Assesses whether the candidate understands KMP's shared-logic-not-shared-UI philosophy and the expect/actual mechanism for bridging platform APIs.

What to say

What to avoid

Example answers

Strong: I put business logic, the API client, models, validation, and caching in commonMain because that's where duplicated bugs across two codebases hurt most, and I keep the UI native in SwiftUI and Compose. When the shared code needs something platform-specific, like secure storage, I declare an expect function in common and provide the actual implementation per platform. I'm upfront that we're trading some build and tooling overhead for one tested copy of the rules, so both teams need to be on board with consuming the module.

Weak: KMP lets you share everything, so I'd move as much as possible into the shared module, including the UI with Compose Multiplatform, to maximize reuse. That way both platforms run the same code and we cut the team size roughly in half.

Want questions matched to your role? Paste a job title, job description, or CV and get a personalized set, or go Pro to unlock the full bank.