美文网首页
disable assert in xcode

disable assert in xcode

作者: yxibng | 来源:发表于2019-11-05 10:49 被阅读0次

最近遇到一个问题,在 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

相关文章

网友评论

      本文标题:disable assert in xcode

      本文链接:https://www.haomeiwen.com/subject/lyrsbctx.html