Chapter 1, Swift vs Objective-C Debugging expression issue

I followed this example as written and ran into an issue, but I believe I found the cause. The correct command appears to be expr -l swift -- import Foundation, not ex -l swift -- import Foundation as shown in the book. If I missed this clarification elsewhere, I apologize.

You’re right — it’s a typo in the book. The correct command is:

expr -l swift -- import Foundation

Using ex -l swift won’t work because expr is required to evaluate Swift expressions in LLDB. This isn’t clarified elsewhere in the chapter.

1 Like

Hello,

l swift, you are explicitly telling the debugger to interpret the following code as Swift, which is necessary if you are debugging a project that mixes languages (like Objective-C and Swift) or if the debugger hasn’t auto-detected the context correctly.