Kotlin Multiplatform

Modern Android Senior Kotlin 2.0+ API 24+ Reviewed By Best Latest Apps

Fill the blank

Declare a platform-specific function in common code.

// commonMain
____ fun platformName(): String

// androidMain
// actual fun platformName(): String = "Android ${android.os.Build.VERSION.SDK_INT}"
Options
Hint 1 of 1

The pair is expect and actual.

Choose an answer, then open Show answer below to check it.

Show answer

Answer: A expect

Correct. Common code declares it; each platform provides an actual.

Why not the others?
  • B actual. That's the platform implementation.
  • C abstract. That's for classes.
  • D external. That's for native (JNI) functions.

30-second answer

Kotlin Multiplatform (KMP) compiles shared Kotlin code to JVM for Android and to native frameworks for iOS. Teams usually share business logic, networking, storage and models, using libraries like Ktor, kotlinx.serialization, SQLDelight or Room and DataStore, which support KMP. Platform APIs use expect/actual. UI can stay native or use Compose Multiplatform.

Practise saying it · 30 s. No recording, just a timer

Explain Kotlin Multiplatform.

Say your answer out loud, then check which of these points you covered:

  • Shared Kotlin for Android and iOS
  • Share logic first
  • expect/actual
  • KMP libraries
  • Swift interop cost

Deep dive

Google officially supports KMP for sharing business logic.

Swift calls Kotlin through generated headers; SKIE or Swift export improve the Swift API.

Coroutines and Flow need wrappers or helpers to feel natural in Swift.

Start with one module, such as networking, and grow.

Common mistakes

  • Sharing UI before logic works.
  • Exposing raw Flow to Swift without a plan.
  • Assuming every Android library works in common code.

Senior take & follow-ups

Say what to share first and the interop cost; be balanced.

Follow-up questions

Think of your answer first, then open the hint.

  1. What does expect/actual do?

    Show hint

    Declares an API in common code and implements it per platform.

  2. What's hard on the iOS side?

    Show hint

    Swift interop for suspend functions, Flow and generics.

Suggest a fix if something here is wrong or out of date.