改进翻译

Kotlin 多平台

多平台项目处于 Alpha 版。语言特性与工具都可能在未来的 Kotlin 版本中发生变化。

Support for multiplatform programming is one of Kotlin’s key benefits. It reduces time spent writing and maintaining the same code for different platforms while retaining the flexibility and benefits of native programming. Learn more about Kotlin Mutliplatform benefits.

With Kotlin Multiplatform, share the code using the mechanisms Kotlin provides:

If you need to access platform-specific APIs from the shared code, use the Kotlin mechanism of expected and actual declarations.

教程

  • Creating a multiplatform Kotlin library teaches how to create a multiplatform library available for JVM, JS, and Native and which can be used from any other common code (for example, shared with Android and iOS). It also shows how to write tests which will be executed on all platforms and use an efficient implementation provided by a specific platform.

  • Building a Full Stack Web App with Kotlin Multiplatform teaches the concepts behind building an application that targets Kotlin/JVM and Kotlin/JS by building a client-server application that makes use of shared code, serialization, and other multiplatform paradigms. It also provides a brief introduction to working with Ktor both as a server- and client-side framework.