func NJLog<T>(message: T,fileName: String = #file,methodName: String = #function,lineNumber: Int = #line) { #if DEBUG // 要把路径最后的字符串截取出来 let fName = ((fileName as NSString).pathComponents.last!) print("\(fName).\(methodName)[\(lineNumber)]: \(message)") #endif }
2.由于Swift没有宏的概念,所以
TARGET -> Build Setting -> Other Swift Flags的Debug状态加一个 -D DEBUG
原文链接:https://www.f2er.com/swift/322124.html