第一次使用 protobu,找不到如何将其连接到 Kotlin Multiplatform 的示例。我创建了带有“共享”模块的多平台项目 Android/IOS,我需要在其中使用 protobuf。项目结构:
build.gradle中的代码shared.module lvl build.gradle共享.module lvl
plugins {
kotlin("multiplatform")
id("com.android.library")
id("com.google.protobuf")
}
kotlin {
android()
listOf(
iosX64(),
iosArm64(),
iosSimulatorArm64()
).forEach {
it.binaries.framework {
baseName = "shared"
}
}
sourceSets {
val commonMain by getting {
dependencies {
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4")
}
}
val commonTest by getting {
dependencies {
implementation(kotlin("test"))
}
}
val androidMain by getting
val androidTest by getting
val iosX64Main by getting
val iosArm64Main by getting
val iosSimulatorArm64Main by getting
val iosMain by creating …
Run Code Online (Sandbox Code Playgroud)