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

后端 未结 1 1362
鱼传尺愫
鱼传尺愫 2020-12-31 19:01

I\'ve been going round and round for a couple days now trying to figure out why my post_install hook isn\'t producing the output I\'m expecting. Here\'s my Podfile:

相关标签:
1条回答
  • 2020-12-31 19:46

    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!

    0 讨论(0)
提交回复
热议问题