Xcode debugger sometimes doesn't display variable values?

This happens to me pretty often. For example, right now I have the debugger stopped at a breakpoint in a method . . . and it isn't displaying any variable values at all. Other times, it displays some, but not others.

Can anyone explain?


The most common reason for this is that you're trying to debug code compiled with optimisation enabled and/or no debug symbols. Typically this will be because you're trying to debug a Release build rather than a Debug build but it can also happen with Debug builds if you've made inappropriate changes to the Debug build settings.

Another less common possibility is that you've hosed the stack.


I had this issue (using Swift), I spent ages crawling through my git commits to find where to problem started.

xcode debugging variables not working or showing


For me, I was using Facebook Tweaks library, but I was (unnecessarily) importing it from my project-bridging-header.h file.

Once I got rid of it, I got my debugging back.

for example, in my bridging header I had:

#ifndef PROJECT_Bridging_Header_h
#define PROJECT_Bridging_Header_h
// Facebook Tweaks
#import "FBTweak.h"
#import "FBTweakStore.h"
#import "FBTweakCategory.h"
#import "FBTweakCollection.h"
#import "FBTweakViewController.h"
#import "FBTweakShakeWindow.h"
#endif

I removed all the imports and just imported it as usual in my AppDelegate import Tweaks.

e.g:

#ifndef PROJECT_Bridging_Header_h
#define PROJECT_Bridging_Header_h
// Removed Facebook Tweaks
#endif

and in my AppDelegate.swift

import Tweaks

This fixed all my debugging issues, everything works as expected and I can also using Facebook Tweaks.

Note: I don't think this is an issue with Facebook Tweaks itself, you may have some other library causing the same issue. The idea is to remove things from your bridging-header one by one and see if you can narrow down the issue.

I think I read somewhere that if a library is causing many issues behind the scenes, this can stop your debugger working.

If this doesn't help, try crawling through your git commits and see at what stage the debugging stopped.

other similar issues on SO:

Xcode Debugging not showing values

Xcode debugger doesn't display variable information after installing CocoaPods Podfile

If you're having similar issues hope this helps! 👍


A possible solution is to set the Optimization Level for your current target Debug scheme to none.

Project -> Target -> Build settings -> Optimization level -> Debug (or whatever fits your project) -> None

Source:

https://stackoverflow.com/a/14948486/3590753


I've had similar issues using LLDB. Switching it back to GDB seems to address it. Obviously this isn't solving the problem, but its a workaround anyway


My issue was that I had address sanitizer enabled. Disabling sanitizer resolved my issue in XCode 8.2.1