Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Switch to Objective-C mode in lldb

Tags:

ios

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.

like image 295
Brennan Vincent Avatar asked Aug 31 '16 16:08

Brennan Vincent


People also ask

What is LLDB commands?

lldb is a command-line debugger (we may see graphical debuggers later in the semester.) “LLVM” is the compiler framework that includes many things, including the clang compiler that we are using, as well as lldb. gdb is another commonly-used debugger.

What is LLDB C++?

lldb is the default debugger in Xcode on macOS and supports debugging C, Objective-C and C++ on the desktop and iOS devices and simulator. All of the code in the LLDB project is available under the Apache 2.0 License with LLVM exceptions.


1 Answers

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/...
like image 150
andreskwan Avatar answered Sep 20 '22 00:09

andreskwan