Weird behaviour of Xcode 11 Debugger – Showing values as nil when there’s a value

This is a known bug, affecting LLDB (the Xcode debugger) as well as the REPL. It’s purely a matter of display:

https://github.com/apple/llvm-project/issues/4477

https://github.com/apple/llvm-project/issues/4479

And see:

Instantiated optional variable shows as nil in Xcode debugger

An easy workaround for now is to pass thru the bridged Objective C type. The bug is only with the Swift Foundation overlay type. So in this case just cast to NSURL.

So for example:

enter image description here

But:

enter image description here

This bug is slated to be fixed in Xcode 12.5.

Leave a Comment