在-Prefix.pch文件中添加如下代码:

#ifdef DEBUG
#define NSLog(...) NSLog(__VA_ARGS__)
#define debugMethod() NSLog(@"%s", __func__)
#else
#define NSLog(...)
#define debugMethod()
#endif

这个DEBUG在哪设置呢,

在 "Target > Build Settings > Preprocessor Macros > Debug" 里有一个"DEBUG=1"。

设置为Debug模式下,Product-->Scheme-->SchemeEdit Scheme
设置Build Configuration成Debug时,就可以打印nslog了。
设置Release,发布app版本的时候就不会打印了,提高了性能
IOS 项目release版本中关闭NSlog的打印

相关文章:

  • 2022-12-23
  • 2022-12-23
  • 2021-09-17
  • 2022-12-23
  • 2022-12-23
  • 2021-09-29
  • 2022-12-23
  • 2021-11-26
猜你喜欢
  • 2022-12-23
  • 2021-12-31
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案