问题
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