美文网首页
Swift3.0-去掉多余的打印

Swift3.0-去掉多余的打印

作者: 殇丶无痕 | 来源:发表于2017-09-30 13:44 被阅读15次

屏蔽多余的打印

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

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<T>(message : T, file : String = #file, lineNumber : Int = #line) {

    #if DEBUG

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

    #endif
}

相关文章

网友评论

      本文标题:Swift3.0-去掉多余的打印

      本文链接:https://www.haomeiwen.com/subject/ihwgextx.html