Xcode 11调试器的怪异行为-有值时将值显示为nil [英] Weird behaviour of Xcode 11 Debugger - Showing values as nil when there's a value

查看:267
本文介绍了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.

例如:

但是:

这篇关于Xcode 11调试器的怪异行为-有值时将值显示为nil的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆