雖然目前 Swift 項(xiàng)目開(kāi)發(fā)比較流行,但是在以前就項(xiàng)目中還是使用 OC 完成開(kāi)發(fā)。
項(xiàng)目重構(gòu)又比較耗費(fèi)時(shí)間,因此在 OC 項(xiàng)目中用 Cocoapods 集成 Swift 庫(kù)是比較常用的方法。
下面是使用此方法遇到的問(wèn)題解決,特此總結(jié)。
- 使用 pod 安裝一個(gè) swift 庫(kù),pod install 報(bào)錯(cuò):
[!] 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.
解決方法:
需要在每個(gè) target 中設(shè)置swift 版本,搜索SWIFT_VERSION,如果沒(méi)有,需要手動(dòng)添加一個(gè)

屏幕快照 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