0Pricing
Kotlin Multiplatform Academy · 课时

目标平台:Android、iOS、桌面、Web、服务器

了解单一 Kotlin 代码库可以编译到哪些平台

目标平台:Android、iOS、桌面、Web、服务器 是 CoddyKit 上的免费 Kotlin Multiplatform Academy 课时。 这是第 3 节课,共 4 节。 你可以在下方免费阅读本课时的完整内容 — 然后在浏览器中使用内置代码编辑器和全天候 AI 导师进行实践。 这是 Kotlin Multiplatform Academy 学习路径的一部分,你的进度在网页和 CoddyKit 应用中同步。 Kotlin Multiplatform Academy 课程共包含 4 节课。

本课时的部分内容尚未翻译,以英文显示。

What Is a Target

A target is a platform your Kotlin code compiles to. One shared codebase can produce builds for several targets at once. 🎯

The Android Target

Android is the most common starting target. Kotlin compiles to JVM bytecode, the same format Android apps have always used.

The iOS Target

For iOS, Kotlin compiles ahead of time into a native binary using Kotlin/Native, packaged as a framework Swift can call.

The Desktop Target

Desktop apps for Windows, macOS, and Linux run on the JVM too. The same desktop target serves all three operating systems.

The Web Target

Kotlin can target the browser by compiling to JavaScript or to WebAssembly, so shared logic runs on the web as well.

The Server Target

On the backend, Kotlin runs on the JVM server side. You can even share models and validation between your app and your API.

Declaring Targets

You list targets in your Gradle build. Each call like androidTarget adds one platform to the shared module.

kotlin {
    androidTarget()
    iosArm64()
    jvm("desktop")
}

Pick Only What You Need

You do not have to ship every target. Most teams start with just Android and iOS and add more targets only when needed.

iOS Has Variants

iOS itself has a few targets: real devices use arm64, while the simulator uses x64 or arm64 depending on your Mac.

Share the Same Source

Every target reads from your common code. That shared source set is compiled fresh for each platform you declared.

One Codebase, Many Outputs

The magic is reach: a single Kotlin codebase becomes an APK, an iOS framework, a desktop app, and more from one build.

Quick Check

Let's confirm what targets are.

Recap

Targets are the platforms you compile to: Android, iOS, desktop, web, and server. Declare only the targets your team actually needs. 🌍

常见问题解答

「目标平台:Android、iOS、桌面、Web、服务器」课时是免费的吗?

是的 — 「目标平台:Android、iOS、桌面、Web、服务器」的完整文本可在网页上免费阅读。要进行交互式练习(内置代码编辑器和全天候 AI 导师)并解锁 Kotlin Multiplatform Academy 课程的其余内容,请升级到 CoddyKit PRO。 Kotlin Multiplatform Academy 课程共包含 4 节课。

「目标平台:Android、iOS、桌面、Web、服务器」这节课中我会学到什么?

了解单一 Kotlin 代码库可以编译到哪些平台 你通过在浏览器中直接运行的动手代码来练习 Kotlin Multiplatform Academy,全天候 AI 导师会在你学习这节课的过程中回答你的问题。

学习 Kotlin Multiplatform Academy 需要有经验吗?

无需任何先前经验。CoddyKit 上的 Kotlin Multiplatform Academy 课程适合初学者到高级学习者,你可以从这里开始或从头开始,按照自己的节奏学习。 这是第 3 节课,共 4 节。

「目标平台:Android、iOS、桌面、Web、服务器」课时需要多长时间?

大多数 CoddyKit 课程大约需要 5–10 分钟。每节课都很精短且互动,所以你能稳步进步,并在网页和应用中从离开的地方继续。

我能在这节 Kotlin Multiplatform Academy 课中编写并运行代码吗?

能。每节 Kotlin Multiplatform Academy 课都包含内置代码编辑器,你可以在浏览器中直接编写并运行真实代码,并获得即时 AI 反馈 — 无需本地设置。

此课程中的所有课时

  1. 共享逻辑而非界面:KMP 的承诺
  2. KMP、Flutter 与 React Native 对比
  3. 目标平台:Android、iOS、桌面、Web、服务器
  4. 目前可以共享和不能共享的内容
← 返回 Kotlin Multiplatform Academy