屏蔽多余的打印
选择Product->Scheme->Edit Scheme ...或者直接按 command + shift + < 快捷键,在弹出的窗口中Environment Variables 下添加 name为OS_ACTIVITY_MODE, value为disable 如图
发布时取消打印,自定义打印代码
- OC代码
#ifndef DEBUG_MODE
#define DLog( s, ... ) NSLog( @"<%p %@:(%d)> %@", self, [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] )
#else
#define DLog( s, ... )
#endif
- Swift代码
func LMRLog<T>(message : T, file : String = #file, lineNumber : Int = #line) {
#if DEBUG
let fileName = (file as NSString).lastPathComponent
print("[\(fileName):line:\(lineNumber)]- \(message)")
#endif
}