未为CocoaPods目标定义DEBUG预处理器宏 [英] DEBUG preprocessor macro not defined for CocoaPods targets
问题描述
我遇到了一个名为DCIntrospect-ARC的pod问题,它只能在DEBUG模式下运行。它检查在运行之前是否定义了DEBUG宏。但是,它没有在CocoaPods目标中定义,即使我在Xcode中以调试模式运行它也无法运行,因为DEBUG宏没有定义。
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.
我可以使用
s.xcconfig = { "GCC_PREPROCESSOR_DEFINITIONS" => '$(inherited) DEBUG=1' }
但这为所有构建配置定义了DEBUG,而不仅仅是DEBUG配置。
but this defined DEBUG for all build configurations and not only the DEBUG configuration.
- 这是一个CocoaPods问题吗?通常不应该为Pods定义DEBUG宏吗?
- 我可以在Podspec文件中解决这个问题,并仅在Debug构建配置中声明DEBUG宏吗?
推荐答案
你可以在Podfile中使用post_install钩子。
you can use the post_install hook in Podfile.
此挂钩允许您在生成的Xcode项目写入磁盘之前对其进行任何最后更改,或者您可能要执行的任何其他任务。
http://guides.cocoapods.org/syntax/podfile.html#post_install
post_install do |installer_representation|
installer_representation.pods_project.targets.each do |target|
target.build_configurations.each do |config|
if config.name != 'Release'
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', 'DEBUG=1']
end
end
end
end
这篇关于未为CocoaPods目标定义DEBUG预处理器宏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!