导入 GoogleWebRTC pod 失败:找不到模块“GoogleWebRTC”

Rém*_*ndt 2 kotlin-native kotlin-multiplatform

我目前正在开发 Kotlin 多平台,并尝试与 GoogleWebRTC pod 进行交互。

该 Pod 存在,我能够将其导入到单独的项目中(没有 Kotlin 多平台)。我可以看到它.framework是在我的构建目录中创建的,但是当执行 gradle 同步或从 Xcode 构建时,我收到以下错误:

Exception in thread "main" java.lang.Error: /var/folders/hv/9cx28nxx4gz9hj_m86bp5rx40000gn/T/tmp362966650322311128.m:1:9: fatal error: module 'GoogleWebRTC' not found
    at org.jetbrains.kotlin.native.interop.indexer.UtilsKt.ensureNoCompileErrors(Utils.kt:152)
    at org.jetbrains.kotlin.native.interop.indexer.ModuleSupportKt.getModulesASTFiles(ModuleSupport.kt:67)
    at org.jetbrains.kotlin.native.interop.indexer.ModuleSupportKt.getModulesInfo(ModuleSupport.kt:13)
    at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.buildNativeLibrary(main.kt:499)
    at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:264)
    at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.interop(main.kt:72)
    at org.jetbrains.kotlin.cli.utilities.InteropCompilerKt.invokeInterop(InteropCompiler.kt:45)
    at org.jetbrains.kotlin.cli.utilities.MainKt.mainImpl(main.kt:19)
    at org.jetbrains.kotlin.cli.utilities.MainKt.main(main.kt:37)

Execution failed for task ':shared:cinteropGoogleWebRTCIosArm64'.
> Process 'command '/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
Run Code Online (Sandbox Code Playgroud)

AFNetworking 似乎工作正常,但添加 WebRTC pod 似乎破坏了该项目。

我是否错过了 Kotlin 多平台的限制或其他什么?

这是我的build.gradle.kts

    cocoapods {
        // Configure fields required by CocoaPods.
        summary = "Some description for a Kotlin/Native module"
        homepage = "Link to a Kotlin/Native module homepage"

        // You can change the name of the produced framework.
        // By default, it is the name of the Gradle project.
        frameworkName = "shared"
        ios.deploymentTarget = "10.0"

        pod("GoogleWebRTC", "~> 1.1")
        pod("AFNetworking", "~> 4.0.0")
    }
Run Code Online (Sandbox Code Playgroud)

sha*_*eep 5

我能够重现这个问题,但我不明白原因。

GoogleWebRTC pod 和 Kotlin-native/cocoapods 集成似乎有问题。

在这里提出了一个问题。

我们有官方帮助。

框架名称似乎与 pod 名称不同。所以一个可能的解决方案可能是:

kotlin {
    cocoapods {
        [...]
        pod("GoogleWebRTC", moduleName = "WebRTC", version = "~> 1.1")
        [...]
    }
    [...]
}
Run Code Online (Sandbox Code Playgroud)

我尝试过并且有效。