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?
谁能解释?
18 个解决方案
#1
37
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.
最常见的原因是,您正在尝试调试用optimisation编译的代码,或者没有调试符号。通常情况下,这是因为您试图调试版本构建而不是调试构建,但是如果您对调试构建设置做出了不适当的更改,也会发生调试构建。
Another less common possibility is that you've hosed the stack.
另一种不太常见的可能性是,你已经把栈顶起来了。
#2
16
I had this issue (using Swift), I spent ages crawling through my git
commits to find where to problem started.
我有这个问题(使用Swift),我花了很多时间爬过我的git,承诺要找到问题的开始。
For me, I was using Facebook Tweaks library, but I was (unnecessarily) importing it from my project-bridging-header.h
file.
对我来说,我使用的是Facebook的微调库,但我(不必要地)从我的项目-bridging-header中导入它。h文件。
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
.
我删除了所有的导入,并像往常一样在AppDelegate导入调整中导入它。
e.g:
例句:
#ifndef PROJECT_Bridging_Header_h
#define PROJECT_Bridging_Header_h
// Removed Facebook Tweaks
#endif
and in my AppDelegate.swift
在我AppDelegate.swift
import Tweaks
This fixed all my debugging issues, everything works as expected and I can also using Facebook Tweaks.
这解决了我所有的调试问题,一切正常,我也可以使用Facebook的调整。
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.注意:我不认为这是Facebook的问题,你可能会有其他的库引起同样的问题。这样做的目的是把你的bridgingheader中的东西一个接一个地删除,看看你是否能缩小问题的范围。
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.
如果这没有帮助,尝试爬过你的git提交,看看调试停止了什么阶段。
other similar issues on SO:
其他类似问题:
Xcode Debugging not showing values
Xcode调试不显示值。
Xcode debugger doesn't display variable information after installing CocoaPods Podfile
Xcode调试器在安装CocoaPods Podfile后不会显示变量信息。
If you're having similar issues hope this helps! ????
如果你有类似的问题,希望这有帮助!????
#3
8
A possible solution is to set the Optimization Level for your current target Debug scheme to none.
一个可能的解决方案是将当前目标调试方案的优化级别设置为none。
Project -> Target -> Build settings -> Optimization level -> Debug (or whatever fits your project) -> None
项目->目标->构建设置->优化级别->调试(或任何适合你的项目)->无。
Source:
来源:
https://*.com/a/14948486/3590753
https://*.com/a/14948486/3590753
#4
6
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
我在使用LLDB时遇到过类似的问题。切换回GDB似乎解决了这个问题。很明显,这并不能解决问题,但无论如何它是一个解决方案。
#5
5
You can get the value of any variable in the console by writing:
您可以通过写入来获得控制台中的任何变量的值:
po name_of_an_objectCVar
or
或
print name_of_a_cVar
#6
2
If your breakpoint has "automatically continue after evaluating options" set, then it won't write to the variable view - FYI
如果您的断点“在评估选项后自动继续”设置,那么它不会写入变量视图- FYI。
#7
1
I know this is old, but i ran into same problem too. I could not see any summaries of any objects, just types and some address code. After 4 hours of struggling with compilers, debuggers and other solutions i was about to give up when by accident i found this option in debugger. "Show Summaries". Just by clicking it everything got fixed and now i see all variable summaries!
我知道这很老,但我也遇到了同样的问题。我看不到任何对象的摘要,只是类型和一些地址代码。在与编译器、调试器和其他解决方案进行了4个小时的斗争之后,我在调试器中发现了这个选项。“总结”。通过点击它,一切都得到了修正,现在我看到了所有的可变摘要!
#8
1
Had the same issue using Xcode 6.4 running the app on device. Running on simulator will show all variables on debugging variables panel.
使用Xcode 6.4在设备上运行应用程序也有同样的问题。在模拟器上运行将显示调试变量面板上的所有变量。
#9
1
There is a situation I have seen where Xcode can't cope with return value optimisation (RVO) -- if the compiler decides to apply RVO to a variable then it may not appear in the variables list. You can disable this in g++ and clang with the compiler flag -fno-elide-constructors
有一种情况,我已经看到Xcode无法处理返回值优化(RVO)——如果编译器决定将RVO应用到一个变量,那么它可能不会出现在变量列表中。您可以在g++和clang中禁用它,并使用编译器标记-fno-elide构造函数。
See also Understanding eliding rules with regard to c++11
还可以了解关于c++11的省略规则。
#10
1
My issue was that I had address sanitizer enabled. Disabling sanitizer resolved my issue in XCode 8.2.1
我的问题是我已经启用了消毒剂。禁用sanitizer解决了我在XCode 8.2.1中的问题。
#11
1
For Swift mix OC Project which use pod
用于快速混合使用pod的项目。
Fixing it by removing useless header(that import with framework by pod) xx-Bridging-Header.h
通过删除无用的头(用框架导入框架)来修复它。
eg. In the past I import header with #import "GCDAsyncSocket.h"
which I was added in podfile
如。在过去,我使用#import“GCDAsyncSocket”导入标题。我被添加到podfile中。
platform:ios, '8.0' use_frameworks! target "roocontrollerphone" do pod 'CocoaAsyncSocket' end
ios平台:,“8.0”use_frameworks !目标“roocontrollerphone”做pod 'CocoaAsyncSocket'端。
just remove it in that xx-Bridging-Header.h
file
把它移到x- bridging - header中。h文件
#12
0
If you are using the @property feature of Objective-C 2.0 the debugger does not display those variables unless they are backed by explicit ivars in your Class interface. This is slated to be fixed in Xcode 4 as I understand it.
如果您使用的是Objective-C 2.0的@property特性,那么调试器不会显示这些变量,除非它们在类接口中有显式的ivars支持。按照我的理解,这将在Xcode 4中修复。
#13
0
temporary solution when it happpen to me : right click on the property jump to definition (u can do it manually and scroll to the @synthesize in the top of the file)
当它发生时,临时解决方案:右键单击属性跳转到定义(u可以手动操作,并在文件顶部滚动到@synthesize)
now, if the line is like this :
如果直线是这样的
@synthesize myObject = _myObject ;
@synthesize myObject = _myObject;
set the mouse cursor on the "_myObjects". that what worked for me..when i have problems.
将鼠标光标放在“_myObjects”上。那对我起作用了。当我有问题。
#14
0
I figured out why it is not working in XCode 4.6 - all of the variables in my object, self, were declared in the .m file instead of the .h. When I moved one of them back to the .h file, it showed up in the debugger. Sounds like a bug with XCode in that it cannot "see" variables declared in the implementation file.
我弄明白了为什么它不能在XCode 4.6中工作——我的对象中的所有变量,self,都是在.m文件中声明的,而不是。h。当我将其中一个移回。h文件时,它出现在调试器中。听起来像一个带有XCode的bug,因为它不能“看到”在实现文件中声明的变量。
#15
0
For me it works changing the content of display variables panel to Local Variables
and then back to Auto
.
对我来说,它可以改变显示变量面板的内容到局部变量,然后返回到Auto。
This solution worked on XCode 6.3.2, Swift type project.
这个解决方案在XCode 6.3.2, Swift类型项目上工作。
#16
0
You need to disable two types of build optimizations in the build settings. By default, the "swift compiler - code generation" optimization level for debug build is set to fast. You need to set this to none. Also check that the "apple llvm 7.1 - code generation" optimization is set to none for debug build. Finally, check that you are building the debug build in the "architectures" section of your build settings.
您需要在构建设置中禁用两种类型的构建优化。默认情况下,调试构建的“快速编译器-代码生成”优化级别被设置为快速。你需要把这个设置为none。还要检查“apple llvm 7.1 -代码生成”的优化是否被设置为没有用于调试构建。最后,检查在构建设置的“体系结构”部分中构建调试构建。
Hope this helps.
希望这个有帮助。
#17
0
I have been stuck a while with this problem and finally find out a solution. I think that many reason can causes this bug but in my case here is the solution. While you are in the breakpoint position check the included classes. I was including using double quote a file which was located using include path.
我被这个问题困住了一段时间,终于找到了解决办法。我认为很多原因可以导致这个错误,但在我的例子中是解决方案。当您处于断点位置时,请检查所包含的类。我使用的是使用包含路径的文件的双引号。
#include "MyClass.h"
instead of
而不是
#include <MyPorject/MyClasses/MyClass.h>
So if you have this problem try to double check your inclusion and import. I know it seems weird but worked for me and I have been able to reproduce it by putting back the Double-Quote include.
因此,如果你有这个问题,试着仔细检查你的包含和导入。我知道这很奇怪,但对我来说很有用,我可以通过把双引号括起来,来复制它。
#18
0
One possible reason for the debugger displaying seemingly wrong values is that the variable type is of Any?
.
调试器显示看似错误的值的一个可能原因是变量类型为Any?
E.g.
如。
var a: Any? = 12
var b: Int? = a as? Int // b=13483920750
var c: Int = a as? Int ?? 0 // c=1
In the example above, b
holds the correct value of 1
even though it is not displayed as such.
在上面的示例中,b的正确值为1,即使它没有显示为这样。
#1
37
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.
最常见的原因是,您正在尝试调试用optimisation编译的代码,或者没有调试符号。通常情况下,这是因为您试图调试版本构建而不是调试构建,但是如果您对调试构建设置做出了不适当的更改,也会发生调试构建。
Another less common possibility is that you've hosed the stack.
另一种不太常见的可能性是,你已经把栈顶起来了。
#2
16
I had this issue (using Swift), I spent ages crawling through my git
commits to find where to problem started.
我有这个问题(使用Swift),我花了很多时间爬过我的git,承诺要找到问题的开始。
For me, I was using Facebook Tweaks library, but I was (unnecessarily) importing it from my project-bridging-header.h
file.
对我来说,我使用的是Facebook的微调库,但我(不必要地)从我的项目-bridging-header中导入它。h文件。
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
.
我删除了所有的导入,并像往常一样在AppDelegate导入调整中导入它。
e.g:
例句:
#ifndef PROJECT_Bridging_Header_h
#define PROJECT_Bridging_Header_h
// Removed Facebook Tweaks
#endif
and in my AppDelegate.swift
在我AppDelegate.swift
import Tweaks
This fixed all my debugging issues, everything works as expected and I can also using Facebook Tweaks.
这解决了我所有的调试问题,一切正常,我也可以使用Facebook的调整。
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.注意:我不认为这是Facebook的问题,你可能会有其他的库引起同样的问题。这样做的目的是把你的bridgingheader中的东西一个接一个地删除,看看你是否能缩小问题的范围。
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.
如果这没有帮助,尝试爬过你的git提交,看看调试停止了什么阶段。
other similar issues on SO:
其他类似问题:
Xcode Debugging not showing values
Xcode调试不显示值。
Xcode debugger doesn't display variable information after installing CocoaPods Podfile
Xcode调试器在安装CocoaPods Podfile后不会显示变量信息。
If you're having similar issues hope this helps! ????
如果你有类似的问题,希望这有帮助!????
#3
8
A possible solution is to set the Optimization Level for your current target Debug scheme to none.
一个可能的解决方案是将当前目标调试方案的优化级别设置为none。
Project -> Target -> Build settings -> Optimization level -> Debug (or whatever fits your project) -> None
项目->目标->构建设置->优化级别->调试(或任何适合你的项目)->无。
Source:
来源:
https://*.com/a/14948486/3590753
https://*.com/a/14948486/3590753
#4
6
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
我在使用LLDB时遇到过类似的问题。切换回GDB似乎解决了这个问题。很明显,这并不能解决问题,但无论如何它是一个解决方案。
#5
5
You can get the value of any variable in the console by writing:
您可以通过写入来获得控制台中的任何变量的值:
po name_of_an_objectCVar
or
或
print name_of_a_cVar
#6
2
If your breakpoint has "automatically continue after evaluating options" set, then it won't write to the variable view - FYI
如果您的断点“在评估选项后自动继续”设置,那么它不会写入变量视图- FYI。
#7
1
I know this is old, but i ran into same problem too. I could not see any summaries of any objects, just types and some address code. After 4 hours of struggling with compilers, debuggers and other solutions i was about to give up when by accident i found this option in debugger. "Show Summaries". Just by clicking it everything got fixed and now i see all variable summaries!
我知道这很老,但我也遇到了同样的问题。我看不到任何对象的摘要,只是类型和一些地址代码。在与编译器、调试器和其他解决方案进行了4个小时的斗争之后,我在调试器中发现了这个选项。“总结”。通过点击它,一切都得到了修正,现在我看到了所有的可变摘要!
#8
1
Had the same issue using Xcode 6.4 running the app on device. Running on simulator will show all variables on debugging variables panel.
使用Xcode 6.4在设备上运行应用程序也有同样的问题。在模拟器上运行将显示调试变量面板上的所有变量。
#9
1
There is a situation I have seen where Xcode can't cope with return value optimisation (RVO) -- if the compiler decides to apply RVO to a variable then it may not appear in the variables list. You can disable this in g++ and clang with the compiler flag -fno-elide-constructors
有一种情况,我已经看到Xcode无法处理返回值优化(RVO)——如果编译器决定将RVO应用到一个变量,那么它可能不会出现在变量列表中。您可以在g++和clang中禁用它,并使用编译器标记-fno-elide构造函数。
See also Understanding eliding rules with regard to c++11
还可以了解关于c++11的省略规则。
#10
1
My issue was that I had address sanitizer enabled. Disabling sanitizer resolved my issue in XCode 8.2.1
我的问题是我已经启用了消毒剂。禁用sanitizer解决了我在XCode 8.2.1中的问题。
#11
1
For Swift mix OC Project which use pod
用于快速混合使用pod的项目。
Fixing it by removing useless header(that import with framework by pod) xx-Bridging-Header.h
通过删除无用的头(用框架导入框架)来修复它。
eg. In the past I import header with #import "GCDAsyncSocket.h"
which I was added in podfile
如。在过去,我使用#import“GCDAsyncSocket”导入标题。我被添加到podfile中。
platform:ios, '8.0' use_frameworks! target "roocontrollerphone" do pod 'CocoaAsyncSocket' end
ios平台:,“8.0”use_frameworks !目标“roocontrollerphone”做pod 'CocoaAsyncSocket'端。
just remove it in that xx-Bridging-Header.h
file
把它移到x- bridging - header中。h文件
#12
0
If you are using the @property feature of Objective-C 2.0 the debugger does not display those variables unless they are backed by explicit ivars in your Class interface. This is slated to be fixed in Xcode 4 as I understand it.
如果您使用的是Objective-C 2.0的@property特性,那么调试器不会显示这些变量,除非它们在类接口中有显式的ivars支持。按照我的理解,这将在Xcode 4中修复。
#13
0
temporary solution when it happpen to me : right click on the property jump to definition (u can do it manually and scroll to the @synthesize in the top of the file)
当它发生时,临时解决方案:右键单击属性跳转到定义(u可以手动操作,并在文件顶部滚动到@synthesize)
now, if the line is like this :
如果直线是这样的
@synthesize myObject = _myObject ;
@synthesize myObject = _myObject;
set the mouse cursor on the "_myObjects". that what worked for me..when i have problems.
将鼠标光标放在“_myObjects”上。那对我起作用了。当我有问题。
#14
0
I figured out why it is not working in XCode 4.6 - all of the variables in my object, self, were declared in the .m file instead of the .h. When I moved one of them back to the .h file, it showed up in the debugger. Sounds like a bug with XCode in that it cannot "see" variables declared in the implementation file.
我弄明白了为什么它不能在XCode 4.6中工作——我的对象中的所有变量,self,都是在.m文件中声明的,而不是。h。当我将其中一个移回。h文件时,它出现在调试器中。听起来像一个带有XCode的bug,因为它不能“看到”在实现文件中声明的变量。
#15
0
For me it works changing the content of display variables panel to Local Variables
and then back to Auto
.
对我来说,它可以改变显示变量面板的内容到局部变量,然后返回到Auto。
This solution worked on XCode 6.3.2, Swift type project.
这个解决方案在XCode 6.3.2, Swift类型项目上工作。
#16
0
You need to disable two types of build optimizations in the build settings. By default, the "swift compiler - code generation" optimization level for debug build is set to fast. You need to set this to none. Also check that the "apple llvm 7.1 - code generation" optimization is set to none for debug build. Finally, check that you are building the debug build in the "architectures" section of your build settings.
您需要在构建设置中禁用两种类型的构建优化。默认情况下,调试构建的“快速编译器-代码生成”优化级别被设置为快速。你需要把这个设置为none。还要检查“apple llvm 7.1 -代码生成”的优化是否被设置为没有用于调试构建。最后,检查在构建设置的“体系结构”部分中构建调试构建。
Hope this helps.
希望这个有帮助。
#17
0
I have been stuck a while with this problem and finally find out a solution. I think that many reason can causes this bug but in my case here is the solution. While you are in the breakpoint position check the included classes. I was including using double quote a file which was located using include path.
我被这个问题困住了一段时间,终于找到了解决办法。我认为很多原因可以导致这个错误,但在我的例子中是解决方案。当您处于断点位置时,请检查所包含的类。我使用的是使用包含路径的文件的双引号。
#include "MyClass.h"
instead of
而不是
#include <MyPorject/MyClasses/MyClass.h>
So if you have this problem try to double check your inclusion and import. I know it seems weird but worked for me and I have been able to reproduce it by putting back the Double-Quote include.
因此,如果你有这个问题,试着仔细检查你的包含和导入。我知道这很奇怪,但对我来说很有用,我可以通过把双引号括起来,来复制它。
#18
0
One possible reason for the debugger displaying seemingly wrong values is that the variable type is of Any?
.
调试器显示看似错误的值的一个可能原因是变量类型为Any?
E.g.
如。
var a: Any? = 12
var b: Int? = a as? Int // b=13483920750
var c: Int = a as? Int ?? 0 // c=1
In the example above, b
holds the correct value of 1
even though it is not displayed as such.
在上面的示例中,b的正确值为1,即使它没有显示为这样。