Mikkel Selsøe Mikkel Selsøe - 4 months ago 64x
iOS Question

DEBUG preprocessor macro not defined for CocoaPods targets

I'm having issues with a pod called DCIntrospect-ARC which should only work in DEBUG mode. It checks if the DEBUG macro is defined before running. However, it is not defined in the CocoaPods target and even though I am running in debug mode in Xcode it fails to run because the DEBUG macro is not defined.

I can define the DEBUG macro in the podspec using

s.xcconfig = { "GCC_PREPROCESSOR_DEFINITIONS" => '$(inherited) DEBUG=1' }

but this defined DEBUG for all build configurations and not only the DEBUG configuration.

  1. Is this a CocoaPods issue? Shouldn't the DEBUG macro generally be defined for Pods?

  2. Can I work around this in the Podspec file and declare the DEBUG macro in the Debug build configuration only?


you can use the post_install hook in Podfile.

This hook allows you to make any last changes to the generated Xcode project before it is written to disk, or any other tasks you might want to perform. http://guides.cocoapods.org/syntax/podfile.html#post_install

post_install do |installer_representation|
    installer_representation.project.targets.each do |target|
        target.build_configurations.each do |config|
            if config.name != 'Release'
                config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', 'DEBUG=1']