Mik*_*søe 19 xcode objective-c ios cocoapods
我遇到了一个名为DCIntrospect-ARC的pod问题,它只能在DEBUG模式下工作.它会在运行之前检查是否定义了DEBUG宏.但是,它没有在CocoaPods目标中定义,即使我在Xcode中以调试模式运行,它也无法运行,因为未定义DEBUG宏.
我可以使用podspec定义DEBUG宏
s.xcconfig = { "GCC_PREPROCESSOR_DEFINITIONS" => '$(inherited) DEBUG=1' }
Run Code Online (Sandbox Code Playgroud)
但是这为所有构建配置定义了DEBUG,而不仅仅是DEBUG配置.
joh*_*ope 22
您可以在Podfile中使用post_install挂钩.
此挂钩允许您在生成的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
Run Code Online (Sandbox Code Playgroud)
Ant*_*ine 11
感谢John,我完成了自定义Podfile脚本,该脚本还将优化级别更改为零并启用断言.
我有多个调试配置(对于ACC和PROD),所以我需要更新几个属性以进行调试.
post_install do |installer|
installer.pods_project.build_configurations.each do |config|
if config.name.include?("Debug")
# Set optimization level for project
config.build_settings['GCC_OPTIMIZATION_LEVEL'] = '0'
# Add DEBUG to custom configurations containing 'Debug'
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)']
if !config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'].include? 'DEBUG=1'
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'DEBUG=1'
end
end
end
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
if config.name.include?("Debug")
# Set optimization level for target
config.build_settings['GCC_OPTIMIZATION_LEVEL'] = '0'
# Add DEBUG to custom configurations containing 'Debug'
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)']
if !config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'].include? 'DEBUG=1'
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] << 'DEBUG=1'
end
# Enable assertions for target
config.build_settings['ENABLE_NS_ASSERTIONS'] = 'YES'
config.build_settings['OTHER_CFLAGS'] ||= ['$(inherited)']
if config.build_settings['OTHER_CFLAGS'].include? '-DNS_BLOCK_ASSERTIONS=1'
config.build_settings['OTHER_CFLAGS'].delete('-DNS_BLOCK_ASSERTIONS=1')
end
end
end
end
end
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
7366 次 |
最近记录: |