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

邮差的信 提交于 2019-11-30 09:47:18

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!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!