Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 530
William Jockusch Avatar asked Jul 11 '10 01:07

William Jockusch


People also ask

How do I display a variable in Xcode?

Select a variable and click the Quick Look button to see a preview of the variable, click the Print Description button to print a description of the object in the console.

What is symbolic breakpoint in Xcode?

It allows you to add a symbolic breakpoint which will halt the execution at a specific point so that you can backtrack and start investigating into where this method call was triggered.

How do I enable debug mode in Xcode?

When you run an application in Xcode, the debugger is automatically started and attached to the process of the application. Click the Run button in the top left or press Command + R. From the moment the application is up and running, we can start inspecting the process and, if necessary, debug it.

How do I debug in Xcode step by step?

To try to debug it, set your active scheme in Xcode to be AppName > iPhone 11 Pro Max. Then using the simulator alone (not Xcode) click on the AppName to let it run. Then go into Xcode and do Debug > Attach to process by PID. Then type in the name of your App, and click Attach.


2 Answers

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.

like image 192
Paul R Avatar answered Oct 09 '22 03:10

Paul R


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! 👍

like image 36
Anil Avatar answered Oct 09 '22 03:10

Anil