Cocoapods pod稳定的构建设置

时间:2017-08-14 11:57:41

标签: ios xcode configuration cocoapods

有没有办法在cocoapods pod中添加构建设置而无需直接更改Pods项目或其他自动生成的内容,因此在pod install之后它仍然存在?具体而言,我需要在Mixpanel pod中设置DISABLE_MIXPANEL_AB_DESIGNER=1以避免崩溃。

我找到了here的内容,但它已经过时了看起来很奇怪,因为(据我所知){pod}所有者创建了podspec文件。

1 个答案:

答案 0 :(得分:0)

谢谢,@ Hodson,这是解决方案。稍微修改了documentation的示例,我们得到了

post_install do |installer|

    #Specify what and where has to be added
    targetName = 'Mixpanel'
    settingKey = 'DISABLE_MIXPANEL_AB_DESIGNER'
    settingValue = 1

    #Find the pod which should be affected
    targets = installer.pods_project.targets.select { |target| target.name == targetName }
    target = targets[0]

    #Do the job
    target.build_configurations.each do |config|
        config.build_settings[settingKey] = settingValue
    end
end

只需将此代码添加到您的podfile即可。显然,以同样的方式,您可以对自动生成的pods项目进行任何更改,并且他们不会迷路。