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

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

问题描述

每次我的应用程序崩溃Xcode突出显示在main()函数中的UIApicationMain()调用作为导致崩溃的行。在某些情况下,以前是正常的(例如分段故障),但崩溃我想处理是一个简单的SIGABRT与详细信息记录在控制台:

  ***由于未捕获异常而终止应用程序'NSInvalidArgumentException',reason:' -  [__ NSCFDictionary setObject:forKey:]:尝试插入nil值(键:Date)'

Xcode用于显示刚好与旧SDK相同的行,但是我升级到Xocde 4.2。
很明显,Xcode知道导致崩溃的原因(或者可能知道),但是它仍然没有显示实际的行。这是否有任何修复或解决方法?

解决方案

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


  1. 在Xcode左侧的项目导航器中,单击断点导航器(几乎一直到顶部按钮栏的右侧)。


  2. 在导航器的底部,请点击+按钮。


  3. 点击添加例外断点 >将创建一个新的断点。


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


你也提到你链接到一些第三方库/框架。如果异常发生在这些框架中,那么你将有一个困难的时间,因为代码编译和Xcode不能实际显示引起异常的行。如果是这种情况,并且您确定您正在使用库,那么您应该向这些库的维护者提交错误报告。


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 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?

解决方案

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. 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).

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

  3. Click "Add Exception Breakpoint".

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

  5. Run your project and reproduce the exception.

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天全站免登陆