Kotlin Help

Kotlin Native

Kotlin/Native is a technology for compiling Kotlin code to native binaries, which can run without a virtual machine. It is an LLVM based backend for the Kotlin compiler and native implementation of the Kotlin standard library.

Why Kotlin/Native?

Kotlin/Native is primarily designed to allow compilation for platforms where virtual machines are not desirable or possible, for example, embedded devices or iOS. It solves the situations when a developer needs to produce a self-contained program that does not require an additional runtime or virtual machine.

Target platforms

Kotlin/Native supports the following platforms:

  • macOS

  • iOS, tvOS, watchOS

  • Linux

  • Windows (MinGW)

  • Android NDK

The full list of supported targets is available here.

Interoperability

Kotlin/Native supports two-way interoperability with the Native world. On the one hand, the compiler creates:

On the other hand, Kotlin/Native supports interoperability to use existing libraries directly from Kotlin/Native:

It is easy to include a compiled Kotlin code into existing projects written in C, C++, Swift, Objective-C, and other languages. It is also easy to use existing native code, static or dynamic C libraries, Swift/Objective-C frameworks, graphical engines, and anything else directly from Kotlin/Native.

Kotlin/Native libraries help to share Kotlin code between projects. POSIX, gzip, OpenGL, Metal, Foundation, and many other popular libraries and Apple frameworks are pre-imported and included as Kotlin/Native libraries into the compiler package.

Sharing code between platforms

Multiplatform projects allow sharing common Kotlin code between multiple platforms, including Android, iOS, JVM, JavaScript, and native. Multiplatform libraries provide required APIs for the common Kotlin code and help develop shared parts of a project in Kotlin code in one place and share it with all or several target platforms.

You can use Kotlin Multiplatform Mobile (KMM) to create multiplatform mobile applications with code shared between Android and iOS.

How to start

Tutorials and documentation

New to Kotlin? Take a look at Getting started with Kotlin.

Recommended documentation:

Recommended tutorials:

Sample projects

Last modified: 21 May 2021