xcode 启用所有异常断点后始终在 App 委托中停止

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

Always stop in App delegate after enabling All exceptions break point

iosobjective-cxcodeswift

提问by Godfather

When i enable all exceptions breakpoint my app always stops in AppDelegate, but im able to continue the program execution, but its very annoying cause always takes me to the appdelegate. Any ideas why?

当我启用所有异常断点时,我的应用程序总是在 AppDelegate 中停止,但我能够继续执行程序,但其非常烦人的原因总是将我带到 appdelegate。任何想法为什么?

enter image description here

在此处输入图片说明

回答by zaph

Only enable Objective-C breakpoints.

只启用 Objective-C 断点。

To see the actual statement that is causing the error add an exception breakpoint:

要查看导致错误的实际语句,请添加异常断点:

  1. From the Main Menu Debug:Breakpoints:Create Exception Breakpoint.

  2. Right-click the breakpoint and set the exception to Objective-C. This will ignore other types of exceptions such as from C++. There are parts of the APIs that use exceptions such as Core Data (Apple is Special).

  3. Add an action: "po $arg1".

  1. 从主菜单 Debug:Breakpoints:Create Exception Breakpoint。

  2. 右键单击断点并将异常设置为 Objective-C。这将忽略其他类型的异常,例如来自 C++ 的异常。API 的某些部分使用了异常,例如 Core Data(Apple 是Special)。

  3. 添加一个动作:“po $arg1”。

Run the app to get the breakpoint and you will be at the line that causes the exception and the error message will be in the debugger console.

运行应用程序以获取断点,您将位于导致异常的行,错误消息将显示在调试器控制台中。

Breakpoint example:

断点示例:

回答by Bryan Cimo

If you're using Swift, or you want to have all the exceptions captured, you can change an option on All Exceptions to automatically continue after evaluating actions. Just find it in the Breakpoint Navigator and right/ctrl click the all Exceptions Breakpoint to edit it: enter image description here

如果您正在使用 Swift,或者您想要捕获所有异常,您可以更改 All Exceptions 上的选项以在评估操作后自动继续。只需在 Breakpoint Navigator 中找到它并右键/ctrl 单击所有 Exceptions Breakpoint 进行编辑: 在此处输入图片说明

Then check the Options box: enter image description here

然后选中选项框: 在此处输入图片说明

回答by Dare

Exceptions in C++ code common and normal. The exception breakpoint catches every raised exception even when they are being handled correctly. So if you don't specify Obj-C only you will notice that execution stops in a lot of seemingly random places. I run into this all the time with AVAudioPlayer especially.

C++ 代码中的异常常见且正常。异常断点会捕获每个引发的异常,即使它们被正确处理。因此,如果您不指定 Obj-C only,您会注意到执行在许多看似随机的地方停止。我一直在用 AVAudioPlayer 遇到这个问题。

Another thing to look out for are missing assets. I came across this question from another asker who seems to have also run into the same issue.

另一件需要注意的事情是丢失的资产。我从另一位提问者那里遇到了这个问题,他似乎也遇到了同样的问题。

Xcode throws an exception in Main() in iOS 8 with 'all exceptions' breakpoint

Xcode 在带有“所有异常”断点的 iOS 8 中的 Main() 中抛出异常