Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
459 views
in Technique[技术] by (71.8m points)

ios - Weird behaviour of Xcode 11 Debugger - Showing values as nil when there's a value

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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:

enter image description here

But:

enter image description here

This bug is slated to be fixed in Xcode 12.5.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...