Xcode调试器显示的变量值不正确 [英] Xcode debugger displays incorrect values for variables

查看:229
本文介绍了Xcode调试器显示的变量值不正确的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我以前在此处问过类似的问题.此版本有一个更简单的示例

I previously asked a similar question here. This version has simpler example

更新后的摘要:Xcode在调试器变量部分为每个String显示"FAIL". Swift print()语句显示正确的变量值.所有其他数据类型显示正确.我该如何返回正常工作的可执行文件?

UPDATED SUMMARY: Xcode is displaying "FAIL" in the debugger variable section for every String. Swift print() statements show correct variable values. All other data types are displaying correctly. How do I get back to a working executable?

问题:Xcode显示的变量值不正确.最初,这是在一个项目中发生的.现在,每个项目,包括新项目,都具有不正确的变量值.这是一个截图,演示了一个新项目中的问题(请原谅我将ViewDidLoad()用作main().)

Problem: Xcode is displaying incorrect values for variables. Originally this happened with one project. Now, EVERY project, including new projects, have incorrect variable values. Here is a screenshot demonstrating the issue in a new project (forgive my use of ViewDidLoad() as main()..)

这就是我所做的:删除Xcode.app(版本10.0).从App Store下载Xcode 10.1.创建一个新项目.输入此代码,然后运行.

Here's what I did: Delete Xcode.app (version 10.0). Download Xcode 10.1 from the App Store. Create a new project. Type in this code, and run.

在Xcode 9.4.1和Xcode 10.0中的现有项目中也会发生相同的问题-与Xcode 10.1的新安装相同的行为.

This same problem occurs in existing projects in Xcode 9.4.1 and Xcode 10.0 -- same behavior as new installation of Xcode 10.1.

由于Xcode的所有版本都显示相同的问题,因此我假设此问题不在Xcode可执行文件中,而是在某些缓存或其他临时文件中.我已经清理了我的项目,重新启动了Xcode,重新启动了,等等.没有帮助.

Since all versions of Xcode show same problem, I am assuming this problem is not in the Xcode executable, but in some cache or other temp file. I have cleaned my project, restarted Xcode, rebooted, etc. No help.

所以我的问题是:如何获得Xcode的全新安装?我可以删除哪些目录才能进入工作状态?我是新手.我只有在iOS调试器或OS X上运行的测试项目,因此我很高兴重新编译所有项目.是否有Xcode使用的临时文件和目录的完整列表?

So my question is: How do I get a clean installation of Xcode? What directories can I delete to get to a working state? I am a novice. I have only test projects that I run in the iOS debugger or on OS X, so I am quite happy re-compiling all of my projects. Is there a complete list of temp files and directories Xcode uses?

我是否必须删除已写入磁盘的所有Xcode?如果没有其他解决方案,我愿意接受.

Do I have to delete EVERYTHING Xcode has ever written to disk? I'm open to that if no other solution exists.

感谢有关如何进行或如何收集更多信息的任何建议...

Thanks for any suggestions on how to proceed or how to gather more info...

推荐答案

经过大量的猜测,我能够解决这个问题.

I was able to solve this one after a LOT of guesswork.

我同意@Martin R的说法,这听起来不像是缓存问题,因为在下载新版本的Xcode之后问题仍然存在.我猜测只有首选项和UserData才能使新的可执行文件过期...

I agreed with @Martin R that this didn't sound like a cache issue, since the problem persisted after downloading new versions of Xcode. I guessed that only preferences and UserData would out-live the new executable...

我查看了UserData目录,并找到了调试器的子目录:

I reviewed the UserData directory, and found a subdirectory for the debugger:

~/Library/Developer/Xcode/UserData/Debugger/

在此目录中有一个名为"CustomDataFormatters"的文件.我不知道文件是如何创建的,但这是它的内容:

In this directory was a file called "CustomDataFormatters". I don't know how the file got created, but here is its contents:

<?xml version="1.0" encoding="UTF-8"?>
<CustomDataFormatters
   version = "1.0">
   <SummaryFormatters>
      <SummaryFormatter
         formatString = "FAIL"
         type = "Swift.String">
      </SummaryFormatter>
   </SummaryFormatters>
</CustomDataFormatters>

此文件似乎将每个字符串设置为"FAIL",这是我看到的确切行为.其他测试显示,整数,浮点数和其他数据类型正确显示-只是String类型始终不正确.

This file seems to set every string to "FAIL", which is the exact behavior I saw. Additional testing showed me that integers, floats, and other data types were displaying correctly -- it was only String type that was always incorrect.

删除此文件解决了我的问题.

Deleting this file solved my problem.

如果任何人都可以解释该文件的创建方式,我将不胜感激,但现在,我可以再次进行调试!

If anyone can explain how this file was created, I would appreciate it, but for now, I am able to debug again!

在应用调试期间,我右键单击了字符串变量以复制"数据或将值查看为...".我在degug期间是否按了一些按键顺序来创建此文件? 尝试CMD + B或CMD + R时是否碰到了一些奇怪的键盘快捷键?

During app debug, I have right clicked on string variables to "copy" data, or "View Value as...". Did I hit some key sequence to create this file during degug? Did I hit some weird keyboard shortcut while trying for a CMD+B or CMD+R??

此外,我将此问题的标题更改为"Xcode调试器对所有字符串显示失败"",以帮助将来进行搜索.

Also, I changed the title of this issue to "Xcode debugger displays "FAIL" for all Strings" to help future searches.

这篇关于Xcode调试器显示的变量值不正确的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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