美文网首页
Swift调试log写法

Swift调试log写法

作者: IOXusu | 来源:发表于2021-02-14 02:41 被阅读0次

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")

相关文章

网友评论

      本文标题:Swift调试log写法

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