【问题标题】:Importing GoogleWebRTC pod fails: module 'GoogleWebRTC' not found导入 GoogleWebRTC pod 失败:找不到模块“GoogleWebRTC”
【发布时间】:2023-04-08 07:43:02
【问题描述】:

我目前正在开发 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

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")
    }

【问题讨论】:

    标签: kotlin-multiplatform kotlin-native


    【解决方案1】:

    我能够重现此问题,但我没有弄清楚原因。

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

    我已经打开了一个问题here。

    我们有官方帮助。

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

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

    我试过了,效果很好。

    【讨论】:

    • 这很好用,但是现在出现这个错误:ld: symbol(s) not found for architecture x86_64 知道是什么原因造成的吗?
    • @RémiVansteelandt 很难说。可能是项目配置错误。您应该提供有关您的项目shared 和iOS 的更多信息,但我认为这应该是一个不同的问题主题。
    • 伙计,你是救生员!我被这个问题困扰了一周!我已经尝试了一切,最后遇到了你的答案,它解决了我的问题。谢谢!
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-10-28
    • 1970-01-01
    • 2019-04-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多