3

Im a little dumfounded with how to use LLDB to inspect an object in a swift project. In this particular case I'm using NSJSONSerializer to serialize a small chunk of JSON and I'd like to inspect the value. In Xcode 5.1 this was super simple, just type "po json" at the lldb prompt and I'd get what I wanted. Now the commands po and print fail me by printing out mostly garbage. I even tried calling the description property because that works with some swift types but that still doesn't work. As a last resort I used an expression with a println statement and finally that works. Surely there must be a better simpler way? Here is the output of LLDB:

(lldb) print json
(AnyObject?) $R4 = (instance_type = Builtin.RawPointer = 0x00007ff05c0c49d0 -> 0x0000000107ef32c8 (void *)0x0000000107ef32f0: __NSCFDictionary)
(lldb) po json
(instance_type = Builtin.RawPointer = 0x00007ff05c0c49d0 -> 0x0000000107ef32c8 (void *)0x0000000107ef32f0: __NSCFDictionary)
 {
 instance_type = 0x00007ff05c0c49d0 -> 0x0000000107ef32c8 (void *)0x0000000107ef32f0: __NSCFDictionary
}
(lldb) print json.description?
error: <EXPR>:1:1: error: 'Optional<AnyObject>' does not have a member named 'description'
json.description?
^ ~~~~~~~~~~~
(lldb) po json.description?
error: <EXPR>:1:1: error: 'Optional<AnyObject>' does not have a member named 'description'
json.description?
^ ~~~~~~~~~~~
(lldb) expression
Enter expressions, then terminate with an empty line to evaluate:
1 println(json)
2 
Optional({
 errors = {
 "authorizations.provider_user_id" = (
 "has already been taken"
 );
 };
})
(lldb) 
asked Nov 12, 2014 at 20:12

1 Answer 1

0

you could try

(lldb) expr -O -d run -- json!

The fact that "po" does not exactly work in the same way it does in ObjC is a known limitation. Explicitly unwrapping the optional, and allowing dynamic type resolution on the unwrapped value should work

Alexander
63.9k13 gold badges105 silver badges175 bronze badges
answered Nov 12, 2014 at 21:53
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.