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
How to Force One Field in Ruby's CSV Output to Be Wrapped with Double-Quotes
How to Find a Model's Relationships
Using the Value of a Variable as Another Variables Name in Ruby
Heroku: How to Push Seeds.Rb to Existing Rails App
Spork 0.9.2 and Rspec 3.0.0 = Uninitialized Constant Rspec::Core::Commandline (Nameerror)
Why Is Devise Not Displaying Authentication Errors on Sign in Page
Aptana 3 Ruby Debugger - Exception in Debugthread Loop: Undefined Method 'Is_Binary_Data'
How to Add Child Nodes in Nodeset Using Nokogiri
How Does MACports Install Packages? How to Activate a Ruby Installation Done via MACports
Using Soap and Other Standard Libraries in Ruby 1.9.2
Escape Double and Single Backslashes in a String in Ruby
What Happens When Modifying Gemfile.Lock Directly
How Would I Go About Programmatically Interacting with VSt(I) Plugins to Synthesize Audio
What Do the Fields of Ruby's Gc.Stat Mean
How to Setup Urls for Static Site with Ruby Rack on Heroku
Rake Db:Migrate Error with MySQL2 Gem - Library Not Loaded: Libssl.1.0.0.Dylib
Ruby: How to Group a Ruby Array
Are Ruby 1.9 Regular Expressions Equally Powerful to a Context Free Grammar