提问者:小点点

Kotlin原生项目中iOS上的libPhonenumber(来自谷歌)


我一直在努力解决一个问题。

我正在使用Kotlin Multiplatform(KMP)构建一个跨平台应用程序(iOS和Android),我需要一个来自谷歌的库(https://github.com/google/libphonenumber).

对于Android,我可以指出Maven回购协议(https://repo1.maven.org/maven2/com/googlecode/libphonenumber/libphonenumber/8.12.6/).

对于iOS,我可以通过Cocoapods使用libPhonenumber的ObjC端口。(https://cocoapods.org/pods/libPhoneNumber-ios).

但是,我无法使用Kotlin的(cocoapod插件)正确识别Pod。该插件似乎无法构建。以下是我的设置的详细信息:

  1. Xcode v11。5
  2. IntelliJ IDEA v2020。1.2
  3. 椰子荚v1。9.1
  4. 格雷德尔6.0。1
  5. 样本回购(https://github.com/touchlab/kotlin-native)注意:在回购协议中,我使用了/样本/椰子荚
  6. 修改/示例/cocoapods/kotlin库/构建。格拉德尔。kts注释掉AFNetworking,移除AFNetworking podpod(“AFNetworking”)~
Downloading dependencies
Installing kotlin_library (1.0)
Installing libPhoneNumber-iOS (0.9.15)
Generating Pods project
Integrating client project
Pod installation complete! There is 1 dependency from the Podfile and 2 total pods installed.

在Xcode中构建示例“ios应用程序”target:simulator时,我得到错误:致命错误:未找到模块“libPhoneNumber”

我尝试过其他libPhoneNumber pod,例如:

  • libPhoneNumberSwift

我错过了什么?


共2个答案

匿名用户

这个特殊的问题似乎是由吊舱名称中的破折号引起的。GitHub上已经报告了一个问题。目前,建议通过重新命名模块来解决此问题。更改您的kotlin库/构建。格拉德尔。ktslike

 pod("libPhoneNumber-iOS", moduleName = "libPhoneNumber_iOS")  

应该有帮助。请试一试,告诉这里或GH如果它的工作。

匿名用户

我通过在IOS中使用JavaScriptCore添加不变的libphonenumber Javascript版本获得了出色的结果。该库中唯一在Javascript中还不可用的部分是地理编码器。我使用了这里解释的概念:https://www.appcoda.com/javascriptcore-swift。性能是伟大的,没有移植参与。始终是可用的最新版本。