I am using cocoapods and want to specify a value in the pod's podspec using the xcconfig parameter that would be specific to Debug mode.
currently, using :
s.xcconfig = { "GCC_PREPROCESSOR_DEFINITIONS" => "MY_DEFINE=1" }
will set the value for both Debug and Release modes. Also tried using :
s.xcconfig = { "GCC_PREPROCESSOR_DEFINITIONS[config=Debug]" => "MY_DEFINE=1" }
but, altho this sets it in the pod's preprocessor macros, it doesn't seem to register during execution of the code, unlike when not using the [config=Debug] tag. Is there a way to limit it to Debug mode only?
You should create two separate podspec's each with different xcconfig and then use configurations to link to each of them:
pod 'my-podspec-debug', :configurations => ['Debug']
pod 'my-podspec-release', :configurations => ['Release']
See this old answer: https://stackoverflow.com/a/26074997/1509221
You can achieve what you need by adding this in your podspec file:
s.xcconfig = { "GCC_PREPROCESSOR_DEFINITIONS" => "$(GCC_PREPROCESSOR_DEFINITIONS_$(CONFIGURATION))",
"GCC_PREPROCESSOR_DEFINITIONS_Debug" => "MY_DEFINE=1" }
You can use Variable Substitution to assign a value to GCC_PREPROCESSOR_DEFINITIONS based on an other variable that its name your create based on the on the build configuration name(i.e. GCC_PREPROCESSOR_DEFINITIONS_$(CONFIGURATION)).
You can read more here https://pewpewthespells.com/blog/xcconfig_guide.html#VariableSubstitution
来源:https://stackoverflow.com/questions/29241458/cocoapods-specify-podspec-xcconfig-value-for-debug-only