Xcode 不显示导致崩溃的行 [英] Xcode doesn't show the line that causes a crash

查看:29
本文介绍了Xcode 不显示导致崩溃的行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

每次我的应用程序崩溃时,Xcode 都会突出显示 main() 函数中的 UIApicationMain() 调用作为导致崩溃的那一行.在某些曾经是正常的情况下(例如分段错误),但我试图处理的崩溃是一个简单的 SIGABRT,在控制台中记录了详细信息:

Every time my app crashes Xcode highlights the UIApicationMain() call in the main() function as the line that caused the crash. In some cases that used to be normal (segmentation fault for example) but the crash I am trying to deal with is a simple SIGABRT with detailed information logged in the console:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFDictionary setObject:forKey:]: attempt to insert nil value (key: Date)'

Xcode 曾经在旧版 SDK 中显示恰到好处的行,但自从我升级到 Xocde 4.2 后就发生了变化.很明显,Xcode 确切地知道是什么导致了崩溃(或可能知道),但它仍然没有显示实际的行.是否有任何修复或解决方法?

Xcode used to show the line just right with older SDKs but since i upgraded to Xocde 4.2 that changed. It is pretty obvious that Xcode knows exactly what caused the crash (or could know), but its still not showing the actual line. Is there any fix or workaround for this?

推荐答案

您还应该确保为所有异常设置了断点.这将导致 Xcode 停止在发生异常的行.[在 Xcode 4 中] 执行以下操作:

You should also ensure that you have breakpoints set for all exceptions. This will cause Xcode to stop at the line where the exception is occurring. Do the following [in Xcode 4]:

  1. 在 Xcode 左侧的 Project Navigator 中,单击断点导航器(几乎一直到顶部按钮栏的右侧.该图标看起来像一个胖右箭头).

  1. In the Project Navigator on the left side of Xcode, click on the breakpoint navigator (almost all the way to the right hand side of the top button bar. The icon looks like a fat right arrow).

在导航器底部,单击+"按钮.

At the bottom of the navigator, click the "+" button.

点击添加异常断点".

将创建一个新断点.它应该根据需要进行配置,但您可以调整其行为.

A new breakpoint will be created. It should be configured as needed but you can tweak its behavior.

运行您的项目并重现异常.

Run your project and reproduce the exception.

您还提到您链接到了一些 3rd 方库/框架.如果异常发生在这些框架内,那么由于代码已编译并且 Xcode 实际上无法向您显示导致异常的行,因此您将遇到困难.如果是这种情况并且您确定自己正确使用了这些库,那么您应该向这些库的维护者提交错误报告.

Also you mentioned that you linked to some 3rd party libraries/frameworks. If the exception is occurring within those frameworks then you are going to have a hard time since the code is compiled and Xcode can't actually show you the line that caused the exception. If this is the case and you are certain you are using the libraries correctly, then you should file a bug report to the maintainers of those libraries.

这篇关于Xcode 不显示导致崩溃的行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆