无法将 Google 的 "NearbyMessages" Cocoapod 添加到 Kotlin/Native 项目
Cannot add Google's "NearbyMessages" Cocoapod to Kotlin/Native project
我想知道是否有人可以帮助我将 cocoapod 添加到 kotlin 原生模块,到目前为止运气不太好!该库是 Google 的 NearbyMessages API。
https://developers.google.com/nearby/messages/ios/get-started
到目前为止我有:
- 使用 cocoapods 示例应用程序克隆了 KMM。 https://github.com/Kotlin/kotlin-with-cocoapods-sample。 (将 kotlin 插件版本号更改为 1.4.21,因为示例中引用的快照似乎不再可用)
- Gradle 同步并构建项目。一切顺利。
- 在 build.gradle.kts 中添加 NearbyMessages pod,就在 AFNetworking 行上方...
pod("NearbyMessages")
- 现在,当我 gradle 同步时,出现以下错误。
> Task :kotlin-library:cinteropNearbyMessagesIosArm64 FAILED
Exception in thread "main" java.lang.Error: /var/folders/t7/gwvnk41x66g5kmr7s7y8thdw0000gn/T/6648793494349780018.m:1:9: fatal error: module 'NearbyMessages' 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:68)
at org.jetbrains.kotlin.native.interop.indexer.ModuleSupportKt.getModulesInfo(ModuleSupport.kt:14)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.buildNativeLibrary(main.kt:507)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:265)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.interop(main.kt:73)
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:41)
Execution failed for task ':kotlin-library:cinteropNearbyMessagesIosArm64'.
> Process 'command '/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
我能够使用 podfile 和 pod install 安装 cocoapod。不涉及 KMM。除此之外,我还尝试了各种随机的方法,但这些步骤似乎应该有效。
这是 NearbyMessages 的 podspec 文件:
https://github.com/CocoaPods/Specs/blob/master/Specs/f/b/9/NearbyMessages/1.1.1/NearbyMessages.podspec.json
JB 小伙伴们已经回答你了here。
为了更好的索引,我在这里报告答案:
Hello, Tom Pratt, thank you for the report! As far as I can see, the
problem is caused by the fact NearbyMessages
pod consists of a static
Objective-C library, not a framework. It has no module.modulemap, so
the cinterop cannot interpret it correctly. Changing
build/cocoapods/defs/NearbyMessages.def
's content to have a headers
option instead of module let me execute cinterop
manually, but I'm not
sure it can be done inside of the Cocoapods Integration.
作为手动解决方法,他们建议:
Also, to make this manual workaround a bit more usable, you can try to
tune the Gradle task generating this .def
file. Just add
tasks.named<DefFileTask>("generateDefNearbyMessages").configure {
doLast {
outputFile.writeText("""
language = Objective-C
headers = GNSMessages.h
""")
}
}
我想知道是否有人可以帮助我将 cocoapod 添加到 kotlin 原生模块,到目前为止运气不太好!该库是 Google 的 NearbyMessages API。 https://developers.google.com/nearby/messages/ios/get-started
到目前为止我有:
- 使用 cocoapods 示例应用程序克隆了 KMM。 https://github.com/Kotlin/kotlin-with-cocoapods-sample。 (将 kotlin 插件版本号更改为 1.4.21,因为示例中引用的快照似乎不再可用)
- Gradle 同步并构建项目。一切顺利。
- 在 build.gradle.kts 中添加 NearbyMessages pod,就在 AFNetworking 行上方...
pod("NearbyMessages")
- 现在,当我 gradle 同步时,出现以下错误。
> Task :kotlin-library:cinteropNearbyMessagesIosArm64 FAILED
Exception in thread "main" java.lang.Error: /var/folders/t7/gwvnk41x66g5kmr7s7y8thdw0000gn/T/6648793494349780018.m:1:9: fatal error: module 'NearbyMessages' 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:68)
at org.jetbrains.kotlin.native.interop.indexer.ModuleSupportKt.getModulesInfo(ModuleSupport.kt:14)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.buildNativeLibrary(main.kt:507)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.processCLib(main.kt:265)
at org.jetbrains.kotlin.native.interop.gen.jvm.MainKt.interop(main.kt:73)
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:41)
Execution failed for task ':kotlin-library:cinteropNearbyMessagesIosArm64'.
> Process 'command '/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java'' finished with non-zero exit value 1
我能够使用 podfile 和 pod install 安装 cocoapod。不涉及 KMM。除此之外,我还尝试了各种随机的方法,但这些步骤似乎应该有效。
这是 NearbyMessages 的 podspec 文件: https://github.com/CocoaPods/Specs/blob/master/Specs/f/b/9/NearbyMessages/1.1.1/NearbyMessages.podspec.json
JB 小伙伴们已经回答你了here。
为了更好的索引,我在这里报告答案:
Hello, Tom Pratt, thank you for the report! As far as I can see, the problem is caused by the fact
NearbyMessages
pod consists of a static Objective-C library, not a framework. It has no module.modulemap, so the cinterop cannot interpret it correctly. Changingbuild/cocoapods/defs/NearbyMessages.def
's content to have a headers option instead of module let me executecinterop
manually, but I'm not sure it can be done inside of the Cocoapods Integration.
作为手动解决方法,他们建议:
Also, to make this manual workaround a bit more usable, you can try to tune the Gradle task generating this
.def
file. Just add
tasks.named<DefFileTask>("generateDefNearbyMessages").configure {
doLast {
outputFile.writeText("""
language = Objective-C
headers = GNSMessages.h
""")
}
}