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. Complete a project for JVM, web, and native platforms, which can be used from any other common code (for example, shared with Android and iOS). Learn how to write tests that can be executed on all platforms and use an efficient implementation provided by a specific platform.
- Get started with Kotlin Multiplatform for mobile. Create your first cross-platform application that works on Android and iOS with the help of the Kotlin Multiplatform Mobile plugin for Android Studio. Learn how to create, run, and add dependencies to multiplatform mobile applications.
- Share UIs between iOS and Android. Create a Kotlin Multiplatform application that uses the Compose Multiplatform UI framework for sharing UIs between iOS and Android.
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.
- Create and 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