3

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

SDGary
  • 434
  • 3
  • 17
  • I doubt that cache files are the problem. – Did you compile with optimization (i.e. in “Release” mode)? Then the compiler can *reuse* the memory of variables which are no longer needed, or hold some variables in registers only. – Martin R Nov 02 '18 at 13:44
  • 1
    (1) Are you running this in the simulator or a device? If simulator, have you tried resetting it (Hardware|Erase All Content and Settings). If device have you tried to delete the app and reboot the device? I've needed to do this when making changes to the launch screen sometimes. (2) Have you deleted the Derived Data (File|Project Settings, then click the arrow to show it in Finder)? Finally, (3) have you tried something like this: https://github.com/Seitk/Xcode-Cleanup-Script ? –  Nov 02 '18 at 14:13
  • Apologies, that repo is 5 years old and may not be a good one. Here's two Swift repos less that one year old: https://github.com/brianramirez/xcode-cleanup https://github.com/onevcat/FengNiao Good luck! –  Nov 02 '18 at 14:15
  • @Martin R Evertyhing seems to be set tor Debug. Its a brand new project running on a newly downloaded Xcode buid, so I expect to be using defaults. My build settings show "Optimization Level" of 0 (-O0) for Debug. My scheme is genertaed automatically. "Edit Scheme" shows Build and Run targets use Debug. – SDGary Nov 02 '18 at 18:01
  • @dfd Great questions. (1) This is an OS X app, running on the simulator on my mac. I also tried this in an iOS app, same code, running in the iOS simulator. Same results. By "resetting the simulator" do you mean exiting and restarting? If so, yes, multiple times for OS X and iOS versions of the app. (2) Yes, I've deleted Derived Data many times. I also clean the project (SHIFT+CMD+K) frequently. Also, restart Xcode and even reboot my mac. (3) This github project deletes DerviedData/* and Archives/* . I hadn't been deleting Archive/* previously. That didn't help -- same results. – SDGary Nov 02 '18 at 18:16

1 Answers1

5

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.

SDGary
  • 434
  • 3
  • 17