虽然目前 Swift 项目开发比较流行,但是在以前就项目中还是使用 OC 完成开发。
项目重构又比较耗费时间,因此在 OC 项目中用 Cocoapods 集成 Swift 库是比较常用的方法。
下面是使用此方法遇到的问题解决,特此总结。
- 使用 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,如果没有,需要手动添加一个
[!] 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