iOS开发-NSLog不打印设置 Prefix
时间 2019-11-18
标签
ios
开发
nslog
打印
设置
prefix
首先在-Prefix.pch,文件里添加以下代码
- #ifdef DEBUG
- #define NSLog(...) NSLog(__VA_ARGS__)
- #define debugMethod() NSLog(@"%s", __func__)
- #else
- #define NSLog(...)
- #define debugMethod()
- #endif
上段代码的意思就是 用宏指令作一个判断,若是DEBUG为真,则编译#ifdef到#endif宏定义,不然编译器就不编译;
这个DEBUG在哪设置呢,
在 "Target > Build Settings > Preprocessor Macros > Debug" 里有一个"DEBUG=1"。(默认好像就是)app
- 设置为Debug模式下,Product-->Scheme-->SchemeEdit Scheme (1)设置Build Configuration成Debug时,就能够打印nslog了。 (2)设置Release,发布app版本的时候就不会打印了,提升了性能