Why can't I step into SwiftUI code?

Was trying to figure out how to do plural localization with SwiftUI.Text, crash inside this:

Text("My dog \("Paula") ate \(2) and \(0)")

so set breakpoint there and single step into went nowhere, just stay on this line and eventually crash again as expected. Didn't get to see what was crashing. Why can't go into whatever inside?

1 Like

SwiftUI is a private Apple framework, and no code is provided. In order for the debugger to step into, it needs the source code, which is not present on your machine. It probably crashed because the source code is not present, and the debugging symbols have been stripped from the release version of the framework, so, for example, the debugger could have been trying to look for the source code file, line number, etc., and those symbols are not present in the stripped framework.

A crash in the debugger is a bug, so you should report it with an example that reproduces the crash. However, @jonprescott's explanation for why you can't debug into SwiftUI is correct.

1 Like

It crash because I did something wrong in Localizable.stringsdict, nothing wrong with the debugger. I was hoping to see what exactly causing the crash inside SwiftUI.Text with the debugger.

But why can't it step into assembly code? It's like something is explicitly telling the debugger not to step inside.

You actually can, there are just two different lldb commands: one steps into an instruction and the other steps over it. In lldb command line, it's si and ni respectively; if you use the Xcode button, you need to hold control to step into.

The thing to keep in mind though is that your disassembly does not necessarily correspond to the source, since many function calls may get inlined. So it could be that the code does not actually make the call you're expecting to step into.