调试时 XCode 调试与发布版本

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3784583/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-09 03:34:04  来源:igfitidea点击:

XCode debug vs release build when debugging

iphonexcodemacos

提问by AlvinfromDiaspar

Ok, i think i've seen it all now.

好的,我想我现在已经看到了。

For about 24 hours i've been trying to debug my app, trying to find where all the weird crashes are coming from all of a sudden. I've been debugging via Simulator/Debug mode. As usual, when i hit a breakpoint, i could see the value of variables (most of the time). Then suddenly i was unable to view variables no matter what i did (btw, im talking about mouse-hovering as for some stupid reason my xcode disabled all the debugging tools from the debug menu).

大约 24 小时以来,我一直在尝试调试我的应用程序,试图找出所有奇怪的崩溃突然发生的地方。我一直在通过模拟器/调试模式进行调试。像往常一样,当我遇到断点时,我可以看到变量的值(大部分时间)。然后突然间,无论我做什么,我都无法查看变量(顺便说一句,我在谈论鼠标悬停,因为出于某种愚蠢的原因,我的 xcode 禁用了调试菜单中的所有调试工具)。

Long story short, out of sheer loss of things to do, i decide to debug with Release mode. Now I can hit breakpoints and see the contents of my variables. And whats even more confusing is that now xcode gives me a much more comprehensive view of the variables that im 'watching' (hovering over).

长话短说,由于完全没有事情要做,我决定使用发布模式进行调试。现在我可以点击断点并查看变量的内容。更令人困惑的是,现在 xcode 为我提供了一个更全面的视图,了解我正在“观察”(悬停)的变量。

I know Apple likes to do things different. But what the heck!? Can somebody please slap me and then tell me what im not understanding here?

我知道苹果喜欢做不同的事情。但到底是什么!?有人可以打我一巴掌,然后告诉我我在这里不明白什么吗?

回答by DarkDust

First, the configurations "Debug" and "Release" are just names, you could also name them "Jon" and "Carla" if you want. They are just names for a configuration sets that you can modify and you can tweak them so that for example the "Debug" configuration is not suitable for debugging any more. So if you (accidentially) disabled generating debug symbols in your "Debug" configuration you would get exactly what you described.

首先,配置“Debug”和“Release”只是名称,如果需要,您也可以将它们命名为“Jon”和“Carla”。它们只是配置集的名称,您可以修改和调整它们,例如“调试”配置不再适合调试。因此,如果您(不小心)在“调试”配置中禁用了生成调试符号,您将得到您所描述的内容。

Go to "Project" -> "Edit active target". Select the "Build" tab and select the "Debug" configuration in the drop down box on the upper left. Select "Show all settings" in the drop down box below and type "debug" in the search bar right next to these two drop down boxes.

转到“项目”->“编辑活动目标”。选择“Build”选项卡,在左上角的下拉框中选择“Debug”配置。在下面的下拉框中选择“显示所有设置”,然后在这两个下拉框旁边的搜索栏中键入“调试”。

There should be a setting "Generate Debug Symbols", make sure its check box is set. "Level of Debug Symbols" should be set to "All Symbols". Also, the "Debug Information Format" should be set to "DWARF with dSYM file".

应该有一个设置“生成调试符号”,确保它的复选框被设置。“调试符号级别”应设置为“所有符号”。此外,“调试信息格式”应设置为“带有 dSYM 文件的 DWARF”。

After changing the settings, clean your project ("Build" -> "Clean") and build again.

更改设置后,清理您的项目(“构建”->“清理”)并再次构建。

Hope that helps.

希望有帮助。