美文网首页
Swift 配置Print

Swift 配置Print

作者: Theshy | 来源:发表于2016-07-22 13:51 被阅读51次

一 OC中配置NSLog输出

//////debug日志输出
#ifdef DEBUG
#define NSLog(...) NSLog(__VA_ARGS__)
#else
#define NSLog(...) {}
#endif

二 swift中配置Print输出

  • project中配置Build Settings
  • 搜索Other Swift 找到Other Swift Flags

如图配置

然后在AppDelegate.swift中加入方法

func Log<T>(_ message: T, file: String = #file, funcName: String = #function, lineNum: Int = #line) {
    #if DEBUG
        let fileName: String = (file as NSString).lastPathComponent
        print("***********Log************\n🐶🐶【\(fileName):\(lineNum)】->>   \(message)")
    #endif
}

然后可以切换 DebugRelease 查看输出信息啦~

相关文章

网友评论

      本文标题:Swift 配置Print

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