为CocoaPods的窗格设置部署目标

我使用CocoaPods来pipe理项目中的依赖关系。 我写了Podfile:

target 'MyApp' do platform :ios, '8.0' # Uncomment this line if you're using Swift or would like to use dynamic frameworks #use_frameworks! # Pods for MyApp pod 'KeepLayout', :git => 'https://github.com/iMartinKiss/KeepLayout', :tag => 'v1.6.0' pod 'EasyMapping' target 'MyAppTests' do inherit! :search_paths # Pods for testing end target 'MyAppUITests' do inherit! :search_paths # Pods for testing end end 

这个文件与CocoaPods 0.x很好地工作,但我已经更新到CocoaPods 1.0后,我不能编译项目。 跑完之后

 pod update 

我无法编译我的项目,错误:

/Users/<…>/Pods/KeepLayout/Sources/KeepAttribute.m:195:1:由于当前部署目标不支持弱引用,无法合成弱属性

我看到每个图书馆都有不同的部署目标。 例如,KeepLayout是用4.3部署目标构build的。

我如何确定每个pod依赖关系的构build目标?

虽然CocoaPods的一些开发版本(以及1.0之前的版本)可能已经将项目的部署目标传播到了吊舱,但在1.0中不再是这种情况 。 要解决这个问题, 目前的开发人员build议使用安装后挂钩。

下面是一个强制的方法来强制生成的Pods项目中每个Pod的硬编码部署目标。 将其粘贴到您的Podfile的末尾:

 post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '9.2' end end end