小编Den*_*ets的帖子

如何在 Android/IOS Kotlin 多平台项目中设置 protobuf

第一次使用 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)

android protocol-buffers ios kotlin kotlin-multiplatform

6
推荐指数
1
解决办法
1553
查看次数