Kotlin 多平台入门
Kotlin Multiplatform is in Beta. It is almost stable, but migration steps may be required in the future. We'll do our best to minimize any changes you have to make.
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 Multiplatform benefits.
Start from scratch
Create and publish a multiplatform 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.
Build 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.
Create your first Kotlin Multiplatform Mobile application shows how to create a mobile application that works on Android and iOS with the help of the Kotlin Multiplatform Mobile plugin for Android Studio. Create, run, and test your first multiplatform mobile application.
Dive deep into Kotlin Multiplatform
Once you have gained some experience with Kotlin Multiplatform and want to know how to solve particular cross-platform development tasks:
Share code on platforms in your Kotlin Multiplatform project.
Connect to platform-specific APIs using the Kotlin mechanism of expected and actual declarations.
Set up targets manually for your Kotlin Multiplatform project.
Add dependencies on the standard, test, or another kotlinx library.
Configure compilations for production and test purposes in your project.
Run tests for JVM, JavaScript, Android, Linux, Windows, macOS, iOS, watchOS, and tvOS simulators.
Publish a multiplatform library to the Maven repository.
Build native binaries as executables or shared libraries, like universal frameworks or XCFrameworks.
Get help
- Kotlin Slack: Get an invite and join the #multiplatform channel
- StackOverflow: Subscribe to the "kotlin-multiplatform" tag
- Kotlin issue tracker: Report a new issue