Xcode 需要很长时间来打印调试结果. [英] Xcode takes long time to print debug results.
问题描述
当我在 Xcode 上调试时,在 Xcode 控制台上打印 po
的结果大约需要 30 秒或更长时间.
When I debug on Xcode it takes around 30 seconds or more to print results of po
on Xcode console.
不幸的是,这只是我掌握的关于该问题的少数信息.
Unfortunately, this is only few information I have on the issue.
但是,还有一点需要考虑.这个问题非常特定于一个项目.这是因为当我将 po
用于同一 Macbook 上的其他项目时,它会立即起作用.此外,这个特定项目在所有其他 Macbook 和所有团队上都很慢.
However, there is another point to consider. This issue is very specific to a project. This is because when I use po
for other projects on same Macbook, it works immediately. Also, this particular project is slow on all other Macbook, and for all team.
我用谷歌搜索但没有找到相关答案.我发现使用 print(...)
而不是在 Xcode 控制台上调试很容易.然而,它需要更多的工作并且需要大量的重建.
I googled it but no relevant answer found. I find it easy to use print(...)
rather than using debugging on Xcode console. However, it's more work and requires lots of rebuilds.
推荐答案
Swift:
试试这个解决方案,它有助于减少调试模式下的日志时间.
Try this solution which helps to reduce log time in debug mode.
步骤 1: 创建一个名为 Utils.swift
的新文件(文件名取决于您的偏好)
Step 1: Create a new file called Utils.swift
(File name based on your preference)
第 2 步:在文件中添加以下代码
import Foundation
import UIKit
struct Utils { }
public func PrintLogs(_ message: Any, file: String = #file, function: String = #function, line: Int = #line) {
#if DEBUG
let className = file.components(separatedBy: "/").last ?? ""
let classNameArr = className.components(separatedBy: ".")
NSLog("\n\n--> Class Name: \(classNameArr[0]) \n--> Function Name: \(function) \n--> Line: \(line)")
print("--> Log Message: \(message)")
#endif
}
用法:调用 PrintLogs("Hello")
而不是 print("Hello")
样本输出:
--> Class Name: HomeViewController
--> Function Name: logTest()
--> Line: 81
--> Log Message: Hello
这篇关于Xcode 需要很长时间来打印调试结果.的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!