Search code examples
iosswiftkotlinkotlin-multiplatformkotlin-native

Is Kotlin Multi-platform Mobile code different from compiled Swift code on iOS platform?


According to docs

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.

So K/N is using LLVM to compile Kotlin code to native code for iOS. Swift compiler also uses LLVM to optimize and generate machine code.

  • So is there any difference between compiled K/N vs compiled Swift code on iOS platform?

    • If so what are those differences? Performance and etc.

Solution

  • The main difference is that Kotlin code compiled for iOS brings along the Kotlin/Native runtime which establishes the Kotlin/Native memory model that aims for safe concurrency and immutability of global objects, and also provides its own garbage collector for Kotlin objects.

    Otherwise, code compiled with Kotlin/Native indeed has two-way interoperability with Swift, as normally the Kotlin binary that you use on iOS is an Objective-C framework that you can import in one project with Swift.