【问题标题】:Cocoapods mix pods with different deployment targetsCocoapods 混合具有不同部署目标的 pod
【发布时间】:2019-07-16 21:36:58
【问题描述】:

我的项目将 iOS 4.3 作为其部署目标。

我所有的 pod 库都支持 4.3,但我也想包括一个,当然不要在 iOS 4.3 设备上使用它的类。

我尝试在我的 Podfile 上使用 target 选项,如下所示:

platform :ios, '4.3'
pod 'NBUCore'

target :MyApp do
    platform :ios, '5.0'
    pod 'PEPhotoCropEditor'
end

它创建了通常的libPods.a 和NBUCore 和一个新的libPods-MyApp.a 和PEPhotoCropEditor,两者都正确链接到MyApp。

问题是有两个.xcconfig 文件,Pods.xcconfig 和Pods-MyApp.xcconfig,但其中只有一个被 Cocoapods 激活,因此链接失败,因为每个文件都有一个不完整的 OTHER_LDFLAGS。

target :test, :exclusive => true 和 false 我都试过了。

当然,我可以手动修改它们,同时使用它们或添加$(inherited) 标志。但是 Cocoapods 应该会处理好这一点。还是我的 Podfile 语法错误?

编辑:事实证明,Pods 和 Pods-MyApp 的“复制 Pods 资源”也需要合并。

【问题讨论】:

    标签: ios objective-c cocoapods


    【解决方案1】:

    在我的 iOS 9.3+ 项目中,我有一个 iOS 11+ 依赖项。为了让它发挥作用,我:

    • 将我的项目和 Podfile 设置为 iOS 11。
    • pod install
    • 将我的项目设置回 iOS 9.3。
    • 在生成的 Pods 项目中,将所有非 3rd 方 Pods-xxx 目标设置为 9.3。
    • 使用预处理器宏来修复任何编译问题。

    原答案

    目前的 Cocoapods 是不可能的(提交了一个问题 here)。

    目前的解决方案是按部署目标分离 Pod:

    platform :ios, '4.3'
    pod 'NBUCore'
    
    target :MyApp do
        platform :ios, '5.0'
        pod 'PEPhotoCropEditor'
    end
    

    然后“合并” .xcconfig 文件。

    最后将所有资源的脚本添加到“Copy Pods Resources”中:

    "${SRCROOT}/Pods/Pods-resources.sh"
    "${SRCROOT}/Pods/Pods-MyApp-resources.sh"
    

    【讨论】:

      【解决方案2】:

      我认为不可能做你想做的事。但是,您可以将PEPhotoCropEditor's Podfile 复制到您的项目并将s.ios.deployment_target = '5.0' 更改为s.ios.deployment_target = '4.3'。

      然后,在您的Podfile 中,而不是

      pod 'PEPhotoCropEditor'
      

      做

      pod 'PEPhotoCropEditor', :path => "CustomPodspec.podspec"
      

      【讨论】:

      • 但是一些 pod 依赖项可能仍然是 iOS5+。我也可以将我的 Podfile 平台更改为 '5.0' 并继续在我的 iOS 4.x 项目中小心使用它,但是随着依赖关系的解决,可能会出现其他问题。
      猜你喜欢
      • 1970-01-01
      • 2015-12-24
      • 1970-01-01
      • 1970-01-01
      • 2020-10-21
      • 1970-01-01
      • 2021-03-25
      • 2020-11-13
      • 1970-01-01
      相关资源
      最近更新 更多