0

所以我正在尝试将我的 KMM 项目导出为 iOS 框架

这是我的 build.gradle.kts

kotlin {
   android()
   ios()
   sourceSets {
    val commonMain by getting {
        dependencies {
            implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.3.0-RC")
            implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.2.1")
            implementation("com.soywiz.korlibs.klock:klock:2.2.2")
            implementation("com.ionspin.kotlin:bignum:0.3.2")
        }
    }
    val commonTest by getting {
        dependencies {
            implementation(kotlin("test-common"))
            implementation(kotlin("test-annotations-common"))
        }
    }
    val androidMain by getting
    val androidTest by getting {
        dependencies {
            implementation(kotlin("test-junit"))
            implementation("junit:junit:4.13.2")
        }
    }

    val iosX64Main by getting
    val iosArm64Main by getting
    val iosMain by getting {
        dependsOn(commonMain)
        iosX64Main.dependsOn(this)
        iosArm64Main.dependsOn(this)
    }
    val iosTest by getting
}

cocoapods {
    framework {
        summary = "Some description for a Kotlin/Native module"
        homepage = "Link to a Kotlin/Native module homepage"
        baseName = "sharedCode"
        isStatic = false
        export(project(":sharedCode"))
        transitiveExport = true
    }
    podfile = project.file("/Users/user/Developments/SampleApp/Podfile")
    ios.deploymentTarget = "14.0"
}
}

这是我的 Podfile

platform :ios, '14.0'
use_frameworks!

target 'Sample App' do
pod 'sharedCode', :path => '/Users/User/Developments/KotlinMultiplatform/sharedCode'
end

每当我从 Android Studio 运行 gradle 同步时,它都会抛出这个错误

Executing of 'pod install' failed with code 1.
Error message:

Please, check that file "/Users/User/Developments/SampleApp/Podfile" contains following lines in header:
source 'https://cdn.cocoapods.org'

Please, check that each target depended on sharedCode contains following dependencies:

然后我尝试pod install从我的终端运行命令,它成功安装了 cocoapods。但是在构建过程中我遇到了另一个问题

* What went wrong:
Execution failed for task ':sharedCode:linkPodDebugFrameworkIosArm64'.

podDebugFramework 二进制文件中导出的以下依赖项未指定为相应源集的 API 依赖项:

Project :sharedCode

Please add them in the API-dependencies and rerun the build.

我在这里想念什么?谢谢

4

1 回答 1

0

我遇到过同样的问题。打开终端并运行 vim .zshrc。添加 LANG=en_US.UTF-8 然后保存。这为我解决了问题。

于 2021-12-05T21:16:14.223 回答