最近遇到一个问题,在 release 环境下,程序执行到了 assert 然后崩溃了。以为release 环境 assert 已经被禁用了,探索了一下,发现并非如此,所以做个记录。
assert
#ifdef NDEBUG
#define assert(e) ((void)0)
#else
NSAssert
Assertions are disabled if the preprocessor macro NS_BLOCK_ASSERTIONS is defined or the ENABLE_NS_ASSERTIONS Xcode build setting is disabled.
禁用 pod 里的 assert 和 NSAssert
post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
if config.name != 'Debug'
config.build_settings['GCC_PREPROCESSOR_DEFINITIONS'] ||= ['$(inherited)', 'NDEBUG', 'NS_BLOCK_ASSERTIONS']
end
end
end
end
网友评论