无法在控制台(调试区)使用 po 命令

Unable to use po command in console (debug area)

突然间我开始随机收到这条消息(但很频繁)

expression produced error: warning: /var/folders/53/0z4yfqt16tvbcn0z7f2385n80000gn/T/expr3-d271e2..swift:3:9: warning: initialization of variable '$__lldb_error_result' was never used; consider replacing with assignment to '_' or removing it var $__lldb_error_result = __lldb_tmp_error ~~~~^~~~~~~~~~~~~~~~~~~~ _

当我尝试在控制台中输入类似这样的内容时:

po myObject

所以,控制台只打印上面的消息,而不是给我一些有用的信息...如何解决这个问题,是什么原因造成的?

lldb 在 Xcode 10.2 中发生了变化。 Apple 建议使用 'p' 或更近期的 'v' 来查看变量的值。

来自 Xcode 10.2 Release Notes

The LLDB debugger has a new command alias, v, for the “frame variable” command to print variables in the current stack frame. Because it bypasses the expression evaluator, v can be a lot faster and should be preferred over p or po. (40066460)

LLDB Tutorial 中名为 检查堆栈帧状态 .

的部分中也有关于此的有用信息

The frame variable command will also perform "object printing" operations on variables (currently we only support ObjC printing, using the object's "description" method. Turn this on by passing the -o flag to frame variable:

(lldb) frame variable -o self 
(SKTGraphicView *) self = 0x0000000100208b40 
<SKTGraphicView: 0x100208b40>

看起来您正在使用 swift。当您升级 Xcode 但未使用新工具集完全重建所有 swift 依赖项时,您可能会遇到此类错误。如果在清除所有依赖项(包括任何 Pods 或 Carthage 模块等)并在本地重新构建它们之后,您仍然会收到此错误,如果这是一个您可以提供的项目,请提交错误http://bugs.swift.org or http://bugreporter.apple.com 我们来看看。

使用 debugprint 命令代替 po 命令。