Kotlin Multi-platform Mobile 代码与 iOS 平台上编译的 Swift 代码是否不同?

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

根据文档

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.

因此 K/N 使用 LLVM 将 Kotlin 代码编译为 iOS 的本机代码。 Swift compiler also uses LLVM to optimize and generate machine code.

主要区别在于,为 iOS 编译的 Kotlin 代码带来了 Kotlin/Native 运行时,它建立了 Kotlin/Native 内存模型,旨在实现全局对象的安全 concurrency and immutability ,并且还为 Kotlin 对象提供了自己的垃圾收集器。

否则用Kotlin/Native编译的代码确实有two-wayinteroperability 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.