Why isn't my cocoapods post_install hook updating my preprocessor macros? Why isn't my cocoapods post_install hook updating my preprocessor macros? ruby ruby

Why isn't my cocoapods post_install hook updating my preprocessor macros?


Found the answer to my specific issue in the way I was adding macros. I had to break the config.build_settings ... line into two lines like so:

post_install do |installer_representation|  installer_representation.project.targets.each do |target|    if target.name == 'Pods-SCCommon-UnitTests-SCCommon'      puts "Setting preprocessor macro for #{target.name}..."      target.build_configurations.each do |config|        puts "#{config} configuration..."        puts "before: #{config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'].inspect}"        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)']        config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'SC_DEBUG_SCCOMMON'        puts "after: #{config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'].inspect}"        puts '---'      end    end  endend

As a side note, I was also setting the definition on the wrong target. Now that both of those issues are resolved, I am officially unstuck! Yay!


I used the code, and it worked.

config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)','MEMORY_LEAKS_FINDER_ENABLED=1','EVERY']

output:

find MLeaksFinder Release$(inherited)MEMORY_LEAKS_FINDER_ENABLED=1EVERYfind MLeaksFinder Debug$(inherited)MEMORY_LEAKS_FINDER_ENABLED=1EVERY