问题
I just noticed weird behaviour of Xcode11, I am executing same code in Xcode 10 and Xcode 11.
See the below attached screenshot for both the versions.
I am creating a url from String, When I put a debugger and check the value of myUrl it shows nil although at very next line it passes nil check and control goes into the not nil case.
See the console too.
have anyone already faced this type of issue? or I am doing something wrong.
P.S: Already Cleared cache, derived data, clean build, restart Xcode. don't confuse with the breakpoint's location, both are captured with different system.
Thanks in advance.
回答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:
回答2:
I am using an answer since for the comment would be too long, but would be more appropriate.
I am currently (catalina, xcode 11.1) facing many similar issues, beside a general slow down of the debugger.
To be sure anyway:
- check that in the target build settings the compile time optimization is disabled for debug: Optimization Level -O0 (the var may be optimized away)
- this solved some of my issues as well (disabling the diagnostic made lldb a bit faster and solved issues with p/po and collecting the stacktrace): Xcode 11 extremely slow - A known problem?
来源:https://stackoverflow.com/questions/58855037/weird-behaviour-of-xcode-11-debugger-showing-values-as-nil-when-theres-a-valu