使用 lldb 呈现 ViewController

present ViewController using lldb

有没有办法直接从 lldb 调试器中呈现 ViewController。 我说的是使用类似的东西:

(lldb) expression SomeViewController.viewDidLoad()

您可以使用 https://github.com/facebook/chisel - 它向调试器添加了一些有用的命令,包括 fvcpvc,它们允许您检查视图控制器。

调试器中有一个 expression 命令可用,它允许您执行代码 - 很像网络浏览器中的 Javascript 控制台。

在这种情况下,您想要:

  1. 暂停应用程序的执行 (Ctrl+Cmd+Y)。
  2. select "main" 在调试导航器中的调用堆栈上 (Cmd+7)
  3. 在调试器中写入以下内容:

e UIApplication.shared.delegate?.window??.rootViewController?.present(viewController, animated: true),其中 viewController 是您要呈现的 VC 实例。

  1. VC 将在您恢复执行后立即显示(另一个 Ctrl+Cmd+Y)。