我怎么知道哪一行代码导致我的iOS应用在Xcode 9中崩溃 [英] How do I know which line of code has caused my iOS app to crash in Xcode 9

查看:143
本文介绍了我怎么知道哪一行代码导致我的iOS应用在Xcode 9中崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Xcode 9(Swift 4)中构建一个应用程序,它在完全加载之前就崩溃了.我收到一个错误:Thread 1: Signal SIGABRTlibc++abi.dylib: terminating with uncaught exception of type NSException.我如何知道使用断点和调试导致错误的代码是哪一行?任何帮助,将不胜感激.谢谢! (这也是屏幕截图)

I am building an app in Xcode 9 (Swift 4) and it crashes before it even loads completely. I get an error: Thread 1: Signal SIGABRT and libc++abi.dylib: terminating with uncaught exception of type NSException. How do I know which line of code is causing the error using breakpoints and debugging? Any help would be appreciated. Thanks! (Here's a screenshot as well)

推荐答案

此处需要的是异常断点.异常断点是一种特殊的断点,它在发生异常时中断,而不是每次都在特定文件的特定行上中断.断点所在的行是引发异常的行.要设置异常断点,您需要打开断点导航器,然后按左下角的+按钮

What you need here is an exception breakpoint. An exception breakpoint is a special kind of breakpoint that breaks whenever an exception occurs, instead of on a specific line in a specific file every time. The line where the breakpoint breaks is the line that throws the exception. To set an exception breakpoint, you'll need to open the breakpoint navigator and press the + button in the bottom left

将会弹出一个小菜单,然后从中选择Exception Breakpoint…

A little menu will pop up, and from that, you select Exception Breakpoint…

此后可能会弹出第三个菜单,但是您可以单击它以外的任何位置以将其关闭.之后,当您再次构建并运行您的应用程序时,只要在抛出该异常的行上抛出异常,它就会中断

A 3rd menu might pop up afterwards, but you can just click anywhere outside of it to dismiss it. After that, when you build and run your app again, it will break whenever an exception is thrown on the line that it is thrown

这篇关于我怎么知道哪一行代码导致我的iOS应用在Xcode 9中崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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