Swift3.0-去掉多余的打印

屏蔽多余的打印

选择Product->Scheme->Edit Scheme ...或者直接按 command + shift + < 快捷键,在弹出的窗口中Environment Variables 下添加 name为OS_ACTIVITY_MODE, value为disable 如图

Swift3.0-去掉多余的打印_第1张图片
2250720-6a8e32abe2a36223.png

发布时取消打印,自定义打印代码

  1. 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 
  1. Swift代码
func LMRLog(message : T, file : String = #file, lineNumber : Int = #line) {

    #if DEBUG

        let fileName = (file as NSString).lastPathComponent
        print("[\(fileName):line:\(lineNumber)]- \(message)")

    #endif
}

你可能感兴趣的:(Swift3.0-去掉多余的打印)