Does the Xcode debugger sometimes not display variable values?

This happens to me quite often. For example, right now I have a debugger stopped at a breakpoint in a method. And it does not display any variable values ​​at all. In other cases, it displays some, but not others.

Can anyone explain?

+41
debugging xcode
Jul 11 '10 at 1:33
source share
18 answers

The most common reason for this is because you are trying to debug code compiled with optimization turned on and / or without debugging symbols. Usually this will be due to the fact that you are trying to debug the Release assembly, not the Debug assembly, but it can also happen with Debug assemblies if you made unulocal changes to the Debug assembly settings.

Another less common possibility is that you have closed the stack.

+35
Jul 11 2018-10-11T00:
source share
β€” -

I had this problem (using Swift), I spent the floor crawling through my git transactions to find where the problem started.

xcode debugging variables not working or showing




I used the Facebook Tweaks library for me, but I (unnecessarily) imported it from my project-bridging-header.h .

As soon as I got rid of it, I got the debugging back.

for example, in my heading, 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 deleted all the imports and simply imported it as usual in my AppDelegate import Tweaks .

eg:

 #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 problems, everything worked as expected, and I can also use Facebook settings.

Note. . I do not think that this is a problem with the Facebook settings, you may have a different library causing the same problem. The idea is to remove things from your bridging-header one by one and see if you can narrow down the problem.

I think I read somewhere that if the library causes a lot of problems behind the scenes, this may stop your debugger from working.

If this does not help, try scanning through git commits and see at what stage debugging is stopped.

other related issues on SO:

Xcode non-value debugging

Xcode Debugger Does Not Display Variable Information After Installing CocoaPods Podcast

If you have similar problems, this will help! πŸ‘

+15
Mar 16 '16 at 20:32
source share

A possible solution is to set the optimization level for your current debugging target scheme to none.

Project β†’ Target β†’ Build Settings β†’ Optimization Level β†’ Debugging (or something that suits your project) β†’ None

Source:

stack overflow

+8
May 05 '14 at 20:03
source share

I had similar problems using LLDB. Switching it back to GDB seems to be addressed to him. Obviously, this is not a solution to the problem, but its workaround is anyway

+6
Nov 11 '11 at 19:13
source share

You can get the value of any variable in the console by writing:

 po name_of_an_objectCVar 

or

 print name_of_a_cVar 
+5
Mar 31 '13 at 13:15
source share

If your breakpoint "automatically continues after evaluating the parameters", then it will not write to the variable view - FYI

+2
Aug 17 '16 at 18:08
source share

I know this is old, but I ran into the same problem. I could not see any summaries of any objects, just types and address code. After 4 hours of struggling with compilers, debuggers, and other solutions, I was about to give up when I accidentally found this option in the debugger. "Show resume." Just clicking on it, everything is fixed, and now I see all the variable summaries!

enter image description here

+1
Apr 04 '13 at
source share

Had the same problem using Xcode 6.4 running the application on the device. Running on the simulator will show all the variables in the debugging options panel.

+1
Aug 24 '15 at 12:28
source share

There is a situation where Xcode cannot cope with return value optimization (RVO) - if the compiler decides to apply RVO to a variable, then it may not appear in the list of variables. You can disable this in g ++ and speak to the compiler flag -fno-elide-constructors

See also Understanding eliding rules regarding C ++ 11

+1
Aug 24 '15 at 12:41
source share

If you use the @property Objective-C 2.0 function, the debugger does not display these variables unless they are supported by explicit ivars in your class interface. This, as I understand it, will be fixed in Xcode 4.

0
Oct 24 '10 at 9:53
source share

workaround when this happened to me: right click on the property go to definition (u can do it manually and scroll to @synthesize at the top of the file)

now if the line is like this:

@synthesize myObject = _myObject;

place the mouse cursor on "_myObjects". something that worked for me ... when i have problems.

0
May 22 '12 at 9:53
source share

I understood why it does not work in Xcode 4.6 - all the variables in my object, I, were declared in the .m file, and not in .h. When I moved one of them back to the .h file, it appeared in the debugger. It sounds like an error with Xcode in that it cannot "see" the variables declared in the implementation file.

0
Apr 12 '13 at 17:33
source share

For me, this changes the contents of the panel of displayed variables to Local Variables , and then back to Auto .

This solution worked on the Xcode 6.3.2 project, Swift.

0
Jun 20 '15 at 13:07
source share

You need to disable two types of build optimization in the build settings. By default, the optimization level β€œfast compiler - code generation” for building debugging is set to fast. You need to set this to none. Also check that the optimization "apple llvm 7.1-code generation" is not set to build debugging. Finally, make sure that you build the debug assembly in the "architecture" section of your build settings.

Hope this helps.

0
May 23 '16 at 12:22
source share

I am stuck with this problem and finally found a solution. I think many reasons can cause this error, but in my case it is a solution. While you are at the breakpoint position, check the included classes. I included the use of a double quote file that was located using the include path.

 #include "MyClass.h" 

instead

 #include <MyPorject/MyClasses/MyClass.h> 

So, if you have this problem, try double checking your inclusion and import. I know this seems strange, but it worked for me, and I was able to reproduce it by including Double-Quote.

0
Jun 08 '16 at 13:22
source share

My problem was that I had a sanitizer on. Disabling the sanitizer resolved my issue in Xcode 8.2.1

0
Mar 05 '17 at 3:26
source share

For a Swift mix OC project that uses pod

Fix this by removing the useless header (which imports using the pod framework) xx-Bridging-Header.h

eg. In the past, I imported the header with #import "GCDAsyncSocket.h" , which was added to the podfile

platform:ios, '8.0' use_frameworks! target "roocontrollerphone" do pod 'CocoaAsyncSocket' end

just delete it in this xx-Bridging-Header.h file

0
May 11 '17 at 11:09 a.m. a.m.
source share

One possible reason for debugging that seems to display incorrect values ​​is because the type of the variable is Any? .

eg.

 var a: Any? = 12 var b: Int? = a as? Int // b=13483920750 var c: Int = a as? Int ?? 0 // c=1 

In the above example, b contains the correct value 1 , even if it is not displayed as such.

0
Aug 05 '17 at 12:50
source share



All Articles