我一直在努力解决一个问题。
我正在使用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。该插件似乎无法构建。以下是我的设置的详细信息:
pod(“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,例如:
我错过了什么?
这个特殊的问题似乎是由吊舱名称中的破折号引起的。GitHub上已经报告了一个问题。目前,建议通过重新命名模块来解决此问题。更改您的kotlin库/构建。格拉德尔。kts
like
pod("libPhoneNumber-iOS", moduleName = "libPhoneNumber_iOS")
应该有帮助。请试一试,告诉这里或GH如果它的工作。
我通过在IOS中使用JavaScriptCore添加不变的libphonenumber Javascript版本获得了出色的结果。该库中唯一在Javascript中还不可用的部分是地理编码器。我使用了这里解释的概念:https://www.appcoda.com/javascriptcore-swift。性能是伟大的,没有移植参与。始终是可用的最新版本。