首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Cocoapods稳定构建设置

Cocoapods稳定构建设置
EN

Stack Overflow用户
提问于 2017-08-14 19:57:41
回答 1查看 174关注 0票数 1

有没有一种方法可以在不直接更改pod项目或其他自动生成的内容的情况下在cocoapods pod中添加构建设置,以便在pod install之后仍然存在?具体地说,我需要在Mixpanel pod中设置DISABLE_MIXPANEL_AB_DESIGNER=1,以避免崩溃。

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

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2017-08-15 17:39:19

谢谢,@Hodson,这就是解决方案。对documentation中的示例稍作修改,我们得到

代码语言:javascript
复制
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项目进行任何更改,并且它们永远不会丢失。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45674027

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档