Xcode 11调试器的怪异行为-有值时将值显示为nil

Xcode 11调试器的怪异行为-有值时将值显示为nil

问题描述:

我刚刚注意到Xcode11的怪异行为,我正在Xcode 10和Xcode 11中执行相同的代码.

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.

我正在从String创建一个url,当我放入调试器并检查myUrl的值时,它显示为nil,尽管在下一行它通过nil,并且控制进入not nil情况.

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.

也请参阅控制台.

有人遇到过此类问题吗?或我做错了什么.

have anyone already faced this type of issue? or I am doing something wrong.

P.S:已清除缓存,派生数据,清理构建,重新启动Xcode.不要与断点的位置混淆,它们都是用不同的系统捕获的.

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.

谢谢.

这是一个已知的错误,会影响LLDB(Xcode调试器)以及REPL.纯粹是显示问题:

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

然后看:

在Xcode调试器中实例化的可选变量显示为nil

目前一个简单的解决方法是通过桥接的Objective C类型.该错误仅与Swift Foundation覆盖类型有关.因此,在这种情况下,只需将其强制转换为NSURL.

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.

例如:

但是: