Unable to inspect local Swift variables or step over await calls in Xcode

The Xcode Swift debugging experience is one of the poorest I've ever had. I use JetBrains and Visual Studio daily alongside Xcode and it's shameful that Apple does not produce a better quality IDE in light of these others that have been capable of such an efficient developer experience as that have already for many, many years.

Does anyone know why Xcode editor does not hover-inspect instance fields but can hover over local variables? I have to then expand self and hunt for the variable in the list. I simply don't understand why this isn't possible. It's infuritating and wastes developer time trying to figure out the contents of an instance variable. There's a great deal more I could write but I won't bother.

I suppose it disappoints me that it seems like it will never get any better. Apple devotes time to AI code completion but no the efficiency and capability of the debugger?

2 Likes

This seems like a very good enhancement request to file via Feedback Assistant. For what it’s worth, I never use the locals window either; I just type p instanceVar in the debugger window. That might be a habit born out of switching to full-time Mac development almost 20 years ago, back when Xcode and its gdb integration were much more primitive.

Please do file feedback reports and share the numbers here. It’s always helpful to hear what people are missing most when they switch from Visual Studio.

Please don’t engage in the fallacy that any feature you don’t use came at the expense of a feature or design change you would have liked to see.

2 Likes

You're right. I guess I would have thought that with millions of developers and thousands of Apple's own developers (and the ones who build Xcode itself) who have to deal with these inefficiencies every single day for years on end in light of the industry alternatives, that tiny developers like me with nothing but a Feedback Assistant wouldn't have to complain and rant so often for years before anything is done. But maybe I'm just delusional! Haha.

For what's it's worth, I'll try to submit my feedback and hope for the best.

3 Likes

In other news, I do love Swift as a language. The if let existing = optional { } and its guard if let variant is one of my favourite things.

I’d would attribute the “inefficiency” to your muscle memory reaching for a Visual Studio feature in a different IDE. Xcode has learned from other editing environments in the past—it gained vim mode a few years ago, which spares me the “inefficiency” of using the wrong shortcuts when I switch between editing code and commit messages. In this case, since Xcode already supports the feature you want on locals, it certainly isn’t helping retrain your muscle memory.

Different ways of doing things is fine. I have to context switch between Visual Studio, JetBrains PhpStorm and Xcode almost every day. Xcode simply fails to live up to the standards of these alternate IDEs in major ways. The debugger makes life slow and laborious. It requires much more manual interaction just to inspect variable contents. Hovering over local variables works, but why doesn’t instance variables in class methods while you’re debugging them? This just doesn’t make any sense. Why do I have to go searching in the watch list, expanding and expanding self.variable.somethingElse whenever I want to just look at a variable in the code editor that happens to be an instance field? This isn’t “doing things different”, this is “strangely missing?”.

I guess my point is that when you have to do this day in day out for years on end, debugging, refactoring and code editing efficiencies and capabilities such as what VS and JB give you make a huge difference over time.

I’m not the only person in the world who finds Xcode to be below the standard that 2024 sets for IDEs, especially from a company as enormous as Apple.

I’ll go and rant politely to the Feedback Assistant.

2 Likes

Thanks for filing, and please do share the feedback numbers here. I interact with many people who have been daily drivers of Visual Studio for many years, and I’m interested in learning where the pain points are when switching to Xcode. Often times, they've spent years accessing equivalent functionality through a different UI path.

1 Like

I submitted one regarding the hovering of variables, "Hovering in code editor is limited to top-level local variables only" - FB15245704

1 Like

I submitted one requesting the ability to disable animations that waste the user's time by blocking any input. Debug variable inspector and Rename Refactor animation being unnecessary. I use these functions significantly and waiting for animations is annoying as heck. FB15245818

P.S. I realised you can disable them in Accessibility but I don't want to do this for the entire system, just Xcode.

3 Likes

Thanks for encouraging me to submit ksluder. I suppose I gave up believing that my feedback would have any effect or ever be seen by anyone (maybe it will, maybe it won't!). I guess my main complaint is really with the debugger. The rest of Xcode I can generally work with fine.

3 Likes

I'd be much more satisfied if the existing features actually worked. They still don't in Xcode 16.

3 Likes

Specifically, the ability to step over and into await calls. FB10899199, FB12250088, FB10012674.

2 Likes

I realized shortly after asking that you were probably referring to the issues that started this thread.

1 Like

It (somewhat) worked in Xcode 15, but it seems completely broken in Xcode 16 again.

Stopping after the guard in something trivial like

        Task {
            do {
                for try await update in CLLocationUpdate.liveUpdates() {
                    guard let location = update.location else {
                        logger.debug("Can't gather location")
                        print("update: \(update)")
                        return
                    }
                    self.location = location
                    logger.debug("New location: \(location)")
                }
            } catch {
                logger.debug("Can't gather location: \(error)")
            }
        }

leads to an unhelpful debugger conversation like that:

(lldb) p update
error: type for self is invalid
error: Couldn't realize Swift AST type of self. Hint: using `v` to directly inspect variables and fields may still work.
(lldb) v update
(CoreLocation.CLLocationUpdate.Updates.Element) update = <Failed to dereference pointer from 0x18faed58 for DW_OP_deref: failed to send packet: 'x18faec00,200'

Ok, in this particular case I'm debugging watchOS (which probably is the most fragile platform to develop I've ever encountered in my 40 years of professional experience), so YMMV.

4 Likes

Can attest to having run into the exact issue you’re describing as well.

1 Like