我使用CocoaPods来管理项目中的依赖关系.我写了一个播客文件:

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之前的版本)可能已经将项目的部署目标传播到了pods,但这是no longer the case in 1.0.要解决这个问题,请使用安装后挂钩.

下面是一种蛮力方法,用于为生成的Pods项目中的每个pod强制执行硬编码部署目标.将此贴在Podfile个选项中的end处:

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

Ios相关问答推荐

如何调整包含extView的UICollectionViewListCell的大小?

如何使视图完全适合屏幕,而不会在旋转时溢出手机屏幕的边界?

如何在iPhone 15上消除.NET Maui中状态栏和页面之间的差距

围绕对象旋转和移动相机不起作用Swift SceneKit

如果没有等待,SWIFT Async让任务抛出取消异常

如何在@AppStorage中存储字体?

在最新版本的 iOS 中,设备上的Localized.strings文件发生了什么变化?

多协议和类继承混乱,Swift

iOS上从谷歌云存储API不断收到网络连接已丢失的错误信息

SwiftUI 故障/错误 - 在 LazyVStack 和 ScrollView 中使用 AVPlayer 时状态栏不显示

如何擦除 Swift 中的 Core Graphics Context 绘图?

xcode-select:找不到clang

卡在 Apple 的 SwiftUI 教程第 5 章(更新应用数据)

错误:无法根据成员environmentObject推断上下文基础

如何包含 Xcode 子项目标头?

从视图模型中更新 EnvironmentObject

如何从一个特定的视图控制器中隐藏导航栏

为信用卡输入格式化 UITextField,例如 (xxxx xxxx xxxx xxxx)

关闭通过模态 segue 显示的视图

打开 XIB 文件后 Xcode 6.3 冻结/挂起