一 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
}
然后可以切換 Debug
和 Release
查看輸出信息啦~