Xcode 调试未显示值

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24065050/
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-15 05:01:02  来源:igfitidea点击:

Xcode Debugging not showing values

objective-cxcode

提问by Patricia

I'm completely stumped. I've been debugging for over a year and have only had this problem when the Build Configuration was set to Release. I have the Build Configuration set to Debug and I have checked to be sure I am attaching to the correct process and yet I still cannot see the values while stepping through the code. Has anybody else ran into this issue?

我完全被难住了。我已经调试了一年多,只有在 Build Configuration 设置为 Release 时才遇到这个问题。我将 Build Configuration 设置为 Debug 并且我已经检查以确保我附加到正确的进程,但在单步执行代码时我仍然看不到这些值。有没有其他人遇到过这个问题?

Here is a screen shot:

这是一个屏幕截图:

enter image description here

在此处输入图片说明

The value is returning, but I am unable to see the values of ANYTHING in this method or any of the other methods and I cannot figure out why.

该值正在返回,但我无法在此方法或任何其他方法中看到 ANYTHING 的值,我无法弄清楚原因。

Thank you for any hints you can give me.

谢谢你给我的任何提示。

============================== UPDATE ==================================

============================== 更新 ================== ================

I've tried to print out the valued and this is the output I receive:

我试图打印出价值,这是我收到的输出:

enter image description here

在此处输入图片说明

Notice though, that the value in the Variables view is correct for the result, even though I can't print it out. But the other values, like filePath should not be nil.

但是请注意,变量视图中的值对于结果是正确的,即使我无法打印出来。但其他值,如 filePath 不应为零。

This is so weird.

这太奇怪了。

============================== UPDATE ==================================

============================== 更新 ================== ================

I put the breakpoint on the return statement and still no luck:

我把断点放在 return 语句上,但仍然没有运气:

enter image description here

在此处输入图片说明

This time I see no value for result:

这次我看不到结果的价值:

enter image description here

在此处输入图片说明

采纳答案by Sujay

I was facing the same issue, On mouse hover and watch section for every variable it was showing nil value but while NSLog for those variables it was printing correct value.

我面临着同样的问题,在鼠标悬停和观察每个变量的部分,它显示 nil 值,但是当这些变量的 NSLog 打印正确值时。

now it's fixed. Try this

现在它固定了。尝试这个

Go to Product menu > Scheme > Edit scheme or ?+<

转到产品菜单 > 方案 > 编辑方案或?+<

In Run go to Info tab, change the build configuration to "debug". Hope it will work.

在运行中转到信息选项卡,将构建配置更改为“调试”。希望它会起作用。

Follow the same

跟着一样

回答by snowbound

@Lucy, ideally you shouldn't have to run in Release profile when debugging, Release is meant as an App Distribution profile with a small package size and little / no debug symbols.

@Lucy,理想情况下,您不必在调试时在 Release 配置文件中运行,Release 是指具有小包大小和很少/没有调试符号的 App Distribution 配置文件。

But if you must debug on Release (e.g. due to Environment, data reasons), make sure you have the Optimization Levelset to 'None' for Release.

但是,如果您必须在发布时进行调试(例如,由于环境、数据原因),请确保将发布的优化级别设置为“无”。

Optimization level

优化级别

You can reach the config above through:

您可以通过以下方式访问上面的配置:

1) Project widesettings - affects all Targets project wide

1)项目范围的设置 - 影响所有目标 项目范围

2) Target specificsetting - affects a single Target only Target specific

2)目标特定设置 - 仅影响单个目标 特定目标

Don't forget to switch this back before App Store distribution. Lower Optimization will generate a larger ipk increasing your users' download time - also the potential dSYM generated.

不要忘记在 App Store 分发之前将其切换回来。较低的优化将生成更大的 ipk,从而增加用户的下载时间 - 也会产生潜在的 dSYM。

Background

背景

For context, Debug, Adhoc or Release profiles are purely to id different build configurations that XCode ships with. XCode starts projects with a Debug profile with no Optimization (and various other predefined config related to development & debugging), so symbol loading by the interpreter is possible - you're free to tweak this however you wish.

对于上下文,Debug、Adhoc 或 Release 配置文件纯粹是为了识别 XCode 附带的不同构建配置。XCode 使用没有优化的调试配置文件启动项目(以及与开发和调试相关的各种其他预定义配置),因此解释器可以加载符号 - 您可以随意调整它。

Theoretically able to establish a Release build profile that's identical to Debug.

理论上能够建立与 Debug 相同的 Release 构建配置文件。

回答by Brad Allred

I do see part of your problem. notice how selfis nil?

我确实看到了你的问题的一部分。通知怎么selfnil

That means you are in a method call for a de-allocated object. Turn on NSZombiesto debug.

这意味着您正在调用取消分配的对象的方法。打开NSZombies调试。

see this SO answerfor how to enable NSZombie

请参阅此 SO 答案以了解如何启用NSZombie

Given that it is legal to send messages to nilin objective-C, I would suspect that the object is being deallocated as a side effect of calling doesLicenseFileExist, or by another thread.

鉴于在 Objective-C 中向其发送消息nil合法的,我怀疑该对象是作为调用的副作用doesLicenseFileExist或由另一个线程释放的。

You may find it helpful to put a breakpoint in IDLicenseCommands -deallocmethod.

您可能会发现在IDLicenseCommands-dealloc方法中放置断点很有帮助。

回答by delta2flat

I had this problem, and turned "Link-Time Optimization" from "Incremental" to "No" and it resolved the debugging issue.

我遇到了这个问题,并将“链接时间优化”从“增量”变为“否”,并解决了调试问题。