ios – 为CocoaPods的pod设置部署目标

我使用 CocoaPods来管理项目中的依赖关系.我写了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: Cannot synthesize weak property because the current deployment target does not support weak references

我看到每个库都是用不同的部署目标构建的.例如,KeepLayout由4.3部署目标构建.

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

解决方法

虽然CocoaPods的一些开发版本(以及1.0版之前版本)可能会将项目的部署目标传播到pod,但这是 no longer the case in 1.0.为了解决这个问题,the current developer recommends使用后安装钩子.

这是一种强制性的方法来强制生成的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

相关文章

UITabBarController 是 iOS 中用于管理和显示选项卡界面的一...
UITableView的重用机制避免了频繁创建和销毁单元格的开销,使...
Objective-C中,类的实例变量(instance variables)和属性(...
从内存管理的角度来看,block可以作为方法的传入参数是因为b...
WKWebView 是 iOS 开发中用于显示网页内容的组件,它是在 iO...
OC中常用的多线程编程技术: 1. NSThread NSThread是Objecti...