Cocoapods pod稳定的构建设置 [英] Cocoapods pod stable build setting

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

问题描述

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

Is there a way to add build setting in a cocoapods pod without direct changing Pods project or other auto-generated stuff, so it will still be in place after pod install? Being specific, I need to set DISABLE_MIXPANEL_AB_DESIGNER=1 in Mixpanel pod to avoid crashes.

我发现了一些东西此处,但它已过时&看起来很奇怪,因为(据我所知) podspec 文件由pod所有者创建,而不是用户。

I've found something here, but it's outdated & looks strange because (as far as I understand) podspec file is created by pod owner, not user.

推荐答案

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

Thanks, @Hodson, it is the solution. Slightly modified the example from documentation, we get

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项目进行任何更改,并且它们不会丢失。

Just add this code to your podfile. Obviously, in the same way you can make any changes to autogenerated pods project, and they won't ever get lost.

这篇关于Cocoapods pod稳定的构建设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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