Why Isn't My Cocoapods Post_Install Hook Updating My Preprocessor MACros

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
end
end

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!

Cocoapod : Redefining preprocess macro using post install hook

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

Objective-C: How to define a macro to disable a piece of source code from pod dependency?

Did it! I built the post_install hook in Podfile to define a custom preprocessor macro, here is it.

# Inject the target macro.
# http://stackoverflow.com/a/27138078/1677041
post_install do |installer|
installer.pods_project.targets.each do |target|
if target.name == "foo_target_name"
target.build_configurations.each do |config|
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)']
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'ADHOC=1'
end
puts "\n\e[3m\e[32mInject a macro ADHOC to target!\e[0m\e[23m\n\n"
end
end
end


Related Topics



Leave a reply



Submit