Cocoapod : Redefining preprocess macro using post install hook
cocoapods, ios, xcode
Solution
In the end, I found a working version.
post_install do |installer_representation|
installer_representation.pods_project.targets.each do |target|
if target.name == "Pods-MyPod"
target.build_configurations.each do |config|
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] = ['COCOAPODS=1', 'FEATURE=0']
end
end
end
end
Problem
I want to update my pod to let users activating/desactivating a feature. To do this I've added a Preprocessor macro in my `podspec` : ``` s.xcconfig = { 'GCC_PREPROCESSOR_DEFINITIONS' => 'FEATURE=1' } ``` Now, for a user the right thing to do (of what I've understood) should be to use a post install hook in the `podfile` to change the definition of `FEATURE` ``` post_install do |installer_representation| installer_representation.project.targets.each do |target| if target.name == "Pods-MyPod" target.build_configurations.each do |config| config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', 'FEATURE=0'] end end end end ``` But it did not do anything at all ... `FEATURE` value is still 1 Am I doing something wrong ? EDIT : I did take a look at this answer, but it did not help.