Xcode debugger displays incorrect values for variables

Viewed 792

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

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?

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()..)

enter image description here

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.

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.

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.

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?

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...

1 Answers

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

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...

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

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

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>

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!

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??

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

Related