我遇到了一个名为 DCIntrospect-ARC 的 pod 的问题,它应该只能在 DEBUG 模式下工作。它在运行前检查是否定义了 DEBUG 宏。但是,它没有在 CocoaPods 目标中定义,即使我在 Xcode 中以 Debug模式运行,它也无法运行,因为没有定义 DEBUG 宏。
我可以在 podspec 中使用定义 DEBUG 宏
s.xcconfig = { "GCC_PREPROCESSOR_DEFINITIONS" => '$(inherited) DEBUG=1' }
但这为所有构建配置定义了 DEBUG,而不仅仅是 DEBUG 配置。
- 这是 CocoaPods 的问题吗?通常不应该为 Pod 定义 DEBUG 宏吗?
- 我能否在 Podspec 文件中解决此问题并仅在调试构建配置中声明 DEBUG 宏?
最佳答案
您可以在 Podfile 中使用 post_install Hook 。
此 Hook 允许您在将生成的 Xcode 项目写入磁盘之前对生成的 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
关于ios - 未为 CocoaPods 目标定义 DEBUG 预处理器宏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21046282/