3

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.

Community
  • 1
  • 1
KIDdAe
  • 2,714
  • 2
  • 22
  • 29
  • 1
    Why is it down voted ? ... Please feel free to explain yourself in the comment and I'll try to update my question. – KIDdAe Feb 27 '15 at 10:57

1 Answers1

6

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
KIDdAe
  • 2,714
  • 2
  • 22
  • 29