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.

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.

nrx
  • 350
  • 4
  • 10
  • Could the `post_install` hook be of use here? https://guides.cocoapods.org/syntax/podfile.html#post_install – Hodson Aug 14 '17 at 13:46
  • @Hodson Indeed, it could :) I've posted an answer based on your comment. – nrx Aug 15 '17 at 10:27

1 Answers1

0

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.

nrx
  • 350
  • 4
  • 10