OC项目中用Cocoapods集成Swift库--问题汇总

虽然目前 Swift 项目开发比较流行,但是在以前就项目中还是使用 OC 完成开发。

项目重构又比较耗费时间,因此在 OC 项目中用 Cocoapods 集成 Swift 库是比较常用的方法。

下面是使用此方法遇到的问题解决,特此总结。

  1. 使用 pod 安装一个 swift 库,pod install 报错:
[!] Unable to determine Swift version for the following pods:

- `AWSMobileClient` does not specify a Swift version and none of the targets (`ESPMeshLibrary`) integrating it have the `SWIFT_VERSION` attribute set. Please contact the author or set the `SWIFT_VERSION` attribute in at least one of the targets that integrate this pod.

解决方法:

需要在每个 target 中设置swift 版本,搜索SWIFT_VERSION,如果没有,需要手动添加一个

屏幕快照 2019-11-18 上午11.23.06.png
[!] The following Swift pods cannot yet be integrated as static libraries:

The Swift pod `AWSMobileClient` depends upon `AWSAuthCore` and `AWSCognitoIdentityProvider`, which do not define modules. To opt into those targets generating module maps (which is necessary to import them from Swift when building as static libraries), you may set `use_modular_headers!` globally in your Podfile, or specify `:modular_headers => true` for particular dependencies.

解决方法:

在podfile中写上use_frameworks!

source 'https://github.com/CocoaPods/Specs.git'

platform :ios, '9.0'
target :'ESPAWSOCDemo' do
    use_frameworks!

    pod 'AWSCore', '~> 2.9.0'
    #pod 'AWSAppSync', '~> 2.10.0'

    pod 'AWSMobileClient', '~> 2.9.0'      # Required dependency
    pod 'AWSAuthUI', '~> 2.9.0'            # Optional dependency required to use drop-in UI
    pod 'AWSUserPoolsSignIn', '~> 2.9.0'   # Optional dependency required to use drop-in UI

    pod 'AWSIoT', '~> 2.9.0'

end
最后编辑于 :
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容