Xcode Debugger Displays Incorrect Values for Variables

Xcode debugger displays incorrect values for variables

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.

Xcode has the wrong debug values while paused in the debugger

I can confirm this bug, looks like debugger UI isn't updating, but the actual data is fine (try to print the value of that array from context menu). I suggest you submit a bug to radar://13755626

Xcode incorrectly displaying the value of watch variables

I found out the problem - its the positioning of the breakpoint, position it a line higher and rvc is not nil.

If you look at the watch window you can see rvc is light text when the other variables are bold text.

So my conclusion is at that point Xcode is reporting that rvc has gone out of scope and been deallocated, yet as the return statement has not yet executed at that point then rvc should not yet have gone out of scope.

Is it some Objective-C optimization thing going on resulting in this in Xcode or is it a defect with Xcode?

Either way its wasted a few hours of my time thinking I had a problem when there wasn't. In the future I need to make sure never to position breakpoints on a return statement again that contains local variables.



Related Topics



Leave a reply



Submit