Kotlin Multiplatform 与 Flutter 对比
KMP(共享业务逻辑 + 原生 UI)与 Flutter(共享 UI + 运行时)——跨平台移动开发对比。性能、开发者体验、生态系统。
用你的 SwiftUI 代码同时发布 iOS 和 Android
Kotlin 语言自 2012 年起;KMP 是生产就绪的共享逻辑 + 原生 UI 模型
现有证据给不出一个明确的“赢家”,只给出明确的“看情况”。Swift 6.3 的官方 SDK 加上 Skip 转为免费开源,第一次让“不学 Kotlin 就进军 Android”这个方案站得住脚。 在生产规模上 KMP 仍然领先:Duolingo、Google、麦当劳、Netflix 等都有大规模落地案例。Skip 的官方展示页也列出了 24 款具名应用,但没有公开的规模或指标数据。 如果你是小团队,没时间学 Kotlin:可以试试 Skip。如果你是企业团队、风险容忍度低:KMP 依然是更稳妥的选择。
| 分类 | Skip (Swift on Android) | Kotlin Multiplatform |
|---|---|---|
| 性能 | 8/10 | 9/10 |
| 学习难易度 | 6/10 | 6/10 |
| 生态系统 | 6/10 | 9/10 |
| 社区 | 5/10 | 9/10 |
| 就业市场 | 4/10 | 8/10 |
| 面向未来 | 7/10 | 9/10 |
// Skip:在已安装 Xcode + Android Studio 的机器上安装并新建项目
// 来源:https://skip.dev/docs/gettingstarted/ + https://skip.dev/docs/skip-cli/
// 1)通过 Homebrew 安装 Skip 工具链
brew install skip
// 2)验证环境(Xcode、Android Studio、Java、Gradle 版本)
skip checkup
// 3)创建一个新的 Skip App 项目(Fuse 模式,iOS+Android)。
// `skip create` 完全是交互式的,不接受参数;非交互式的对应命令是 `skip init`:
skip init --native-app --appid=com.example.HelloSkip hello-skip HelloSkip
// 4)如果想以 Library 模式给现有 iOS 应用添加 Android 支持:
// 把共享逻辑抽取到一个独立的原生库模块中
skip init --native-model shared-feature SharedFeature
// 你像写普通 iOS SwiftUI 视图一样编写生成的 SwiftUI 视图:
import SwiftUI
struct ContentView: View {
@State private var count = 0
var body: some View {
VStack(spacing: 16) {
Text("用 Skip 发布到 Android")
.font(.title2)
Text("计数:\(count)")
Button("增加") {
count += 1
}
.buttonStyle(.borderedProminent)
}
.padding()
}
}
// 5)在 Android 端编译并运行(通过 Gradle,后台会将
// SwiftUI 视图树转换为 Jetpack Compose 调用)。
// 前提条件:需要自己启动模拟器 —— `skip app launch` 不会替你启动。
cd hello-skip
skip android emulator launch
skip app launch --android// Kotlin Multiplatform:共享逻辑 + expect/actual
// 来源:https://kotlinlang.org/docs/multiplatform/get-started.html
// commonMain/kotlin/Counter.kt —— 所有平台共享的逻辑
class Counter {
private var value: Int = 0
fun increment(): Int { value += 1; return value }
fun current(): Int = value
}
// commonMain/kotlin/Platform.kt
expect fun platformName(): String
// androidMain/kotlin/Platform.android.kt
actual fun platformName(): String = "Android ${android.os.Build.VERSION.SDK_INT}"
// iosMain/kotlin/Platform.ios.kt
import platform.UIKit.UIDevice
actual fun platformName(): String =
UIDevice.currentDevice.systemName() + " " + UIDevice.currentDevice.systemVersion
// Android 端的 Compose UI 使用共享的 Counter
@Composable
fun CounterScreen(counter: Counter) {
var count by remember { mutableStateOf(counter.current()) }
Column(modifier = Modifier.padding(16.dp)) {
Text("使用 Kotlin Multiplatform 共享的逻辑")
Text("计数:$count")
Button(onClick = { count = counter.increment() }) { Text("增加") }
}
}
// build.gradle.kts (module: shared)
kotlin {
androidTarget()
listOf(iosX64(), iosArm64(), iosSimulatorArm64()).forEach {
it.binaries.framework { baseName = "Shared" }
}
sourceSets {
commonMain.dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0")
}
}
}现有证据给不出一个明确的“赢家”,只给出明确的“看情况”。Swift 6.3 的官方 SDK 加上 Skip 转为免费开源,第一次让“不学 Kotlin 就进军 Android”这个方案站得住脚。 在生产规模上 KMP 仍然领先:Duolingo、Google、麦当劳、Netflix 等都有大规模落地案例。Skip 的官方展示页也列出了 24 款具名应用,但没有公开的规模或指标数据。 如果你是小团队,没时间学 Kotlin:可以试试 Skip。如果你是企业团队、风险容忍度低:KMP 依然是更稳妥的选择。
获取免费咨询可以。截至 Swift 6.3(2026 年 3 月 24 日),官方已经推出了 Swift SDK for Android,Swift 包可以直接编译到 Android 目标平台。Skip 这类工具在此基础上,把 SwiftUI 视图转换成真正的 Jetpack Compose 界面,提供了一套实用的开发流程。来源:swift.org/blog/swift-6.3-released。