Switch to Objective-C mode in lldb

When I debug a Swift application in Xcode, the debugger expects an expression in Swift format. How can I switch it to expect an Objective-C expression?

For example, I want to be able to type expr id $foo = [[SomeClass alloc] initWithBar:@"quux"];Swift instead of any equivalent.

+6
source share
2 answers

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

(lldb) help <language>

Swift 4.0

(lldb) help <source-language>

Create an alias like "eco" to print target-c objects

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

Xcode LLDB WWDC 2018 , :

expression -l objc -O -- [doYourStuff here]

, Swift Objective C . , , , :

error: use of undeclared identifier 'self'

, , '. :

expression -l objc -O -- ['self' class]
0

Source: https://habr.com/ru/post/1653188/


All Articles