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

前端之家收集整理的这篇文章主要介绍了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
原文链接:https://www.f2er.com/iOS/329896.html

猜你在找的iOS相关文章