Share
11 April 2026

Kotlin Multiplatform (KMP)

Kotlin Multiplatform (KMP) is an open-source technology developed by JetBrains that enables developers to share common code across different platforms—including Android, iOS, desktop, and web—using a single codebase written in the Kotlin programming language.

With Compose Multiplatform, you can also share UI code across multiple platforms for maximum code reuse.


Why does multi-platform hurt?

When building apps for multiple platforms like:

  • Android
  • iOS
  • Web
  • Desktop

each platform has its own ecosystem:

  • Different languages (Kotlin, Swift, JavaScript)
  • Different UI frameworks
  • Different runtime environments

That’s why:

  • iOS apps don’t run on Android
  • Android apps don’t run on Web
  • Desktop apps don’t run on iOS

What actually happens

Each platform has its own language, UI framework, and runtime. Even identical logic (login, API calls, validation) must be rewritten per platform.


How KMP works under the hood

In Kotlin Multiplatform (KMP), the project structure is centered around the concept of targets. Here is how it works:

What are Targets?

  • target represents a specific platform you want your application to run on, such as AndroidiOSDesktop(macOS, Windows, Linux), or Web.
  • target is a specific platform + runtime combination. You declare targets in your Gradle config; the compiler generates a separate binary for each.
  • Each platform has its own unique way of executing code. For example, Android runs on the JVM (Java Virtual Machine), while iOS runs on native binariesspecific to its CPU architecture.

The Kotlin compiler targets each platform separately — no single universal binary. It generates exactly the right output for each target.

  • Instead of forcing a single format on every device, the Kotlin compiler is intelligent enough to handle these differences.
  • When you build your project, the compiler generates the specific output needed for each selected target:
    • For Android, it compiles the shared code into Java bytecode to be executed by the JVM .
    • For iOS, it compiles the same shared code into native binaries that the iOS system can execute directly.

What KMP gives you

  • Direct Native API Access: Unlike other frameworks that require a “bridge layer” to communicate between the cross-platform code and the host operating system, KMP compiles directly to the platform’s native format.
  • Superior Performance: By eliminating the bridge layer, KMP avoids the interpretation overhead often found in other cross-platform solutions, allowing your code to run with the performance of a native application.
  • Native Integration: Because KMP targets the native format of each OS (e.g., Java bytecode for the JVMon Android and native binaries for iOS), you can call platform-specific system APIs (like hardware sensors or notifications) directly from your shared Kotlin code .

In essence, KMP provides the efficiency of sharing code without sacrificing the control and performance you get from writing platform-specific native code.


Limitations

What KMP cannot do (yet)

  • Library Constraints : You are restricted to using pure Kotlin libraries within your shared code. Libraries written in Java cannot be used in the shared module because they often rely on the JVM (Java Virtual Machine), which is not available on non-JVM platforms like iOS.
  • Hardware Requirements for Apple Platforms : If you intend to build or compile iOS or macOSapplications using KMP, you are required to have a Mac. While you can still develop and write code for these platforms on other operating systems, you will not be able to build or run the final iOS application without Apple hardware.
  • Build System Dependencies : KMPtypically utilizes Gradle for building and dependency management. For a library to be compatible with KMP, it must be specifically configured to support every platform target, which is not the default behavior for older Java libraries.

📚 References

Overview:

https://kotlinlang.org/docs/multiplatform/kmp-overview.html

Folder Structure CMP

https://kotlinlang.org/docs/multiplatform/compose-multiplatform-create-first-app.html#run-your-application