Search code examples
ioslldb

Switch to Objective-C mode in lldb


When I am debugging a Swift app in Xcode, the debugger expects expressions in Swift format. How can I switch it to expect Objective-C expressions instead?

E.g., I want to be able to type expr id $foo = [[SomeClass alloc] initWithBar:@"quux"]; instead of whatever the Swift equivalent is.


Solution

  • Swift 3.0 or before use: You can use the following command to identify the name of all available languages in LLDB.

    (lldb)help <language>

    Swift 4.0

    (lldb)help <source-language>

    Create an alias like "eco" to print objective-c objects:

    (lldb)command alias eco expression -l objective-c -o --
    (lldb)eco [[UIApplication sharedApplication] userHomeDirectory] 
    /Users/...