为CocoaPods的pod设置部署目标 [英] Set deployment target for CocoaPods's pod

查看:919
本文介绍了为CocoaPods的pod设置部署目标的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I use CocoaPods to manage dependencies in my project. I've written 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后我无法编译项目。在我运行之后

This file works well with CocoaPods 0.x but I can't compile project after I've updated to CocoaPods 1.0. After I've run

pod update 

我无法编译错误项目:


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

/Users/<...>/Pods/KeepLayout/Sources/KeepAttribute.m:195:1: Cannot synthesize weak property because the current deployment target does not support weak references

我已经看到每个库都使用不同的部署目标进行构建。例如,使用4.3部署目标构建KeepLayout。

I've seen that every library is builded with different deployment target. For example KeepLayout is builded with 4.3 deployment target.

如何确定每个pod依赖项的构建目标?

How I can determine build target for every pod dependency?

推荐答案

虽然CocoaPods的一些开发版本(以及1.0之前的版本)可能已经将项目的部署目标传播下来对于pod,这是不再是1.0的情况。要解决此问题,请使用安装后挂钩当前开发人员建议

While some development versions of CocoaPods (as well as pre-1.0 versions) may have propagated the deployment target of the project down to the pods, this is no longer the case in 1.0. To work around this, the current developer recommends using a post-install hook.

这是一种强制方法,用于强制生成的Pods项目中每个pod的硬编码部署目标。将其粘贴到Podfile的末尾:

Here's a brute force approach to force a hard-coded deployment target for every pod in the generated Pods project. Paste this at the end of your 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

这篇关于为CocoaPods的pod设置部署目标的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆