Cocoapods pod stable build setting

混江龙づ霸主 提交于 2019-12-20 04:17:07

问题


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.

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.


回答1:


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

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.



来源:https://stackoverflow.com/questions/45674027/cocoapods-pod-stable-build-setting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!