Cocoapods pod stable build setting

前端 未结 1 1792
忘掉有多难
忘掉有多难 2021-01-23 09:31

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

1条回答
  •  囚心锁ツ
    2021-01-23 09:58

    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.

    0 讨论(0)
提交回复
热议问题