Swift debugging in Xcode - I can't look in to my dictionary contents

If I put a simple dictionary such as this in a new Xcode project:


var myDictionary:[String: String] = [
            "a": "line 1",
            "b": "line 2"]



I would expect to be able to look browse the contents of the dictionary when I'm debugging in Xcode. However all Xcode tells me is:


myDictionary [String : String] 0 key/value pairs


For Arrays and object you normally have the foldable tree structure to look in to the contents. The closest I can see to this right now in Xcode for a dictionary is a "Print Description" option when I right click that spits the entire contents of the dictionary in the console but this isn't exactly what I need


I'm not certain if this was happening before I switched to Xcode 8 or not. I had only been using swift for a short while before switching to Xcode 8. I think it is likely that it wasn't happening before the switch because it's likely i would have noticed it then


Is there any settings I can change so that I can see the contents of this dictionary in my debugger?

Answered by Scifo in 194749022

I've solved this myself now (for the most part). It only happens when I debug using the iPhone 5 in the simulator. If I even move up to iPhone 5s the debugger works as I would expect.


This still leaves a bug where you can't debug properly on an iPhone 5 but this is not an issue for me. It is maybe something Apple would need to look at themselves though

This works for me in Xcode 8. Where do you declare this variable (top level, local variable in a function, instance variable, etc)? Where is the breakpoint where you are observing the variable relative to the declaration (same instance, same file, in the instance's init, before or after the declaration)?


I can provoke the behaviour you are seeing by breaking before the declaration, but then it is not supposed to have a value, not even be visible, but for some reason Xcode shows it anyway. Is that what you are seeing?

No thanks for trying but this isn't what I'm seeing. It happens any time I try to look at any dictionary in my project even when I know the dictionary I'm attempting to look at should have been populated long before.


For testing purposes I created a brand new project and added this simple dictionary into my initial delegate in the first function then put the break point on the 'true' after I have written this dictionary. The result was the same


I don't think the problem is therefore related to either how I'm debugging or my actual project, if I were to hazard a guess I would think there is an Xcode config affecting me.


I also use Jetbrains AppCode as well as Xcode and I get the exact same problem there as well. It does not show me the contents of my dictionaries

Accepted Answer

I've solved this myself now (for the most part). It only happens when I debug using the iPhone 5 in the simulator. If I even move up to iPhone 5s the debugger works as I would expect.


This still leaves a bug where you can't debug properly on an iPhone 5 but this is not an issue for me. It is maybe something Apple would need to look at themselves though

Swift debugging in Xcode - I can't look in to my dictionary contents
 
 
Q