一般項目中我的NSLog會在Prefix.pch文件添加如下代碼,已保證在非調(diào)試狀態(tài)下NSLog不工作,
下面就是我自定義的BTlog代替系統(tǒng)的NSLog打印輸出.
#ifdef DEBUG
#define BTLog(FORMAT, ...) fprintf(stderr,"%s:%d\t%s\n",[[[NSString stringWithUTF8String:__FILE__] lastPathComponent] UTF8String], __LINE__, [[NSString stringWithFormat:FORMAT, ##__VA_ARGS__] UTF8String]);
#else
#define BTLog(...)
#endif
PS:要實現(xiàn)該功能,還需要做配置配置文件
將Preprocessor Macros 下的 Debug 添加? DEBUG=1,Release不加;