How to Use Po Command in Console (Debug Area)

Unable to use po command in console (debug area)

lldb has changed in Xcode 10.2. Apple recommends use of 'p' or more recently 'v' to view the values of variables.

from the 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)

There is also good information on this in the LLDB Tutorial in the section named Examining Stack Frame State.

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>

po command in Xcode does not generate output

Silly me, I was in the 'Target Output' window instead of the 'Debugger Output' window.

Sample Image

Somehow I thought I checked the other console windows there, but apparently I didn't.

How to access 'self' in Console in Xcode 7.3

You can check the values of properties and variables using po [self variablename] in console window. This way you can easily access the variables.

Also you can check with other projects weather the problem is with xcode or in your project configurations.

You can also expand the collapsed value in debug area. if it's expanding then you can access values by simply using po variablename otherwise you need to use po [self variablename].

Sample Image

What's the difference between p and po in Xcode's LLDB debugger?

Strip debug symbols during copy

In most answers they advice to set optimization to "none" but forget that this option should be set to NO (at least for debug configuration).

Useful Xcode DEBUG commands to use in console

You can find it in Apple documentation: Debugging with Xcode

or check this: https://developer.apple.com/library/content/documentation/IDEs/Conceptual/gdb_to_lldb_transition_guide/document/lldb-command-examples.html



Related Topics



Leave a reply



Submit