如何调试 SwiftUI AttributeGraph 循环警告?

Sin*_*hus 13 debugging macos xcode swiftui

我在使用 SwiftUI 的应用程序中收到了很多 AttributeGraph 循环警告。有没有办法调试导致它的原因?

这是控制台中显示的内容:

=== AttributeGraph: cycle detected through attribute 11640 ===
=== AttributeGraph: cycle detected through attribute 14168 ===
=== AttributeGraph: cycle detected through attribute 14168 ===
=== AttributeGraph: cycle detected through attribute 44568 ===
=== AttributeGraph: cycle detected through attribute 3608 ===
Run Code Online (Sandbox Code Playgroud)

Asp*_*eri 25

日志由(来自私有AttributeGraph.framework)生成

AG::Graph::print_cycle(unsigned int) const ()
Run Code Online (Sandbox Code Playgroud)

所以你可以设置符号断点 print_cycle

演示

而且,它有多大帮助取决于您的场景,但肯定会在 Xcode 中得到错误生成的堆栈。

  • `$ nm /System/Library/PrivateFrameworks/AttributeGraph.framework/AttributeGraph` (3认同)

wri*_*nds 14

对我来说,这个问题是由于我在用户仍在编辑文本字段时禁用它引起的。

要解决此问题,您必须首先放弃该文本字段作为第一响应者(从而停止编辑),然后禁用该文本字段。我在这个Stack Overflow 答案中对此进行了更多解释。