Weird behaviour of Xcode 11 Debugger - Showing values as nil when there's a value
Solution 1:
This is a known bug, affecting LLDB (the Xcode debugger) as well as the REPL. It's purely a matter of display:
https://bugs.swift.org/plugins/servlet/mobile#issue/SR-11593
https://bugs.swift.org/plugins/servlet/mobile#issue/SR-11546
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:
But:
This bug is slated to be fixed in Xcode 12.5.