1.新建Common.swift
2.内容如下
func printLogDebug<T>(message: T, file: String = __FILE__,method: String = __FUNCTION__,line: Int = __LINE__)
{
#if DEBUG
print("\((file as NSString).lastPathComponent) [\(line)], \(method): \(message)")
#endif
}
3.配置
Build Settings -> 搜索Swift -> Other Swift Flags 的值设置为 -D DEBUG, 去除调试删除该值即可
4.使用
printLogDebug("hello")
网友评论