如何调试:libc ++ abi.dylib:以NSException类型的未捕获异常终止? [英] How do I debug: libc++abi.dylib: terminating with uncaught exception of type NSException?

查看:60
本文介绍了如何调试:libc ++ abi.dylib:以NSException类型的未捕获异常终止?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

很抱歉问这个菜鸟问题,我知道它已经被问过数千遍了,我知道,因为我已经有数千次问过这个问题了.但是这次,谷歌没有帮助.

Sorry for asking this noob question, I know it has been asked thousands of times before, I know because I've had this problem thousands of times before. But this time google isn't helping.

错误/终端打印:

libc++abi.dylib: terminating with uncaught exception of type NSException

我通常知道是什么类型的情况导致这种情况,因为我过去曾遇到过此问题,并且修复起来非常简单,通常是函数名称错误或某些UI元素与我的代码之间的链接断开,但是现在我有了不知道是什么原因造成的.

I generally know what type of situations cause this because I have had this issue in the past and it was quite simple to fix, usually a misnamed function or a broken link between some UI element and my code, but right now I have no idea what could be causing it.

我已经尝试过的方法:

我在启动ViewController的过程中添加了很多断点,它通过所有@IBOutlets都不会引发任何问题.我在AppDelegate的所有方法中都添加了断点,并且断点在任何地方都没有.代码在到达任何viewDidLoad()方法之前会崩溃.我已经清理了我的项目,重新启动了XCode一千次,甚至破坏并重新构建了UI和代码之间的每个链接.重命名,然后为每个@IBAction重新分配.

I've added tonnes of breakpoints on the starting ViewController and it goes through all the @IBOutlets without throwing any issues. I've added breakpoints in all the methods in the AppDelegate and it doesn't break anywhere there. The code crashes before it reaches any viewDidLoad() methods. I've cleaned my project, restarted XCode a thousand times and even broken and re-made every link between UI and code. Renamed and then reassigned every @IBAction.

在这一点上,我什至不知道我没有尝试过什么.每个stackoverflow帖子始终都是关于检查断开的链接等"的同一件事,但这已经无济于事了.我不记得自己做了什么更改,因为在开始收到此错误之前,我更改了很多小东西.我尝试将所有内容放回原处,但这似乎无济于事.

At this point I don't even know what I haven't tried. Every stackoverflow posts is always about the same thing "check broken links etc" but that just isn't helping anymore. I can't remember what it was that I changed because I changed so many small things before I started getting this error. I tried putting everything back but that didn't seem to help.

应用崩溃时:

"applicationDidBecomeActve()"完成后,调试器进入一堆机器代码,然后应用崩溃,我得到了:

Right after "applicationDidBecomeActve()" is finished the debugger goes into a bunch of machine code, then the app crashes and I get this:

正确链接的证明:

[由于不必要而删除的图像]

[Images removed as they were unneccessary]

我的主要问题:

如果链接不是这里的问题,那还能是什么?

If linking is not the issue here, what else could it be?

关于NSLogs/堆栈跟踪

我很乐意提供某种NSLog或堆栈跟踪,就像我看到人们在其他问题上提出的要求和意见一样,但我不知道如何做到.我在互联网上找不到任何从石器时代就如何开启它们的东西.所有其他一切都只是如何使用调试器,但是我正在使用调试器,并且所获得的只是对代码的简要了解,一看机器指令,直到它最终崩溃为止.

I would love to provide some sort of NSLog or stack trace as I have seen people ask and give for on other questions but I have no idea how. I cannot find anything on the internet that isn't from the stone age on how to turn them on. And everything else is just how to use the debugger, but I am using the debugger and all I am getting are brief glimpses of my code in a see of machine instructions until it finally just crashes.

显然,我只能在仿真器而不是物理设备上运行时获取日志.这是在模拟器上运行时得到的日志:

Apparently I can only get logs when running on an emulator instead of physical device. Here are the logs I get when running on emulator:

objc[40258]: Class PLBuildVersion is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/AssetsLibraryServices.framework/AssetsLibraryServices (0x123242998) and /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator.sdk/System/Library/PrivateFrameworks/PhotoLibraryServices.framework/PhotoLibraryServices (0x123067d38). One of the two will be used. Which one is undefined.
2016-11-04 16:26:47.463 KotConnect[40258:1345011] Unknown class ProgressViewContainer in Interface Builder file.
2016-11-04 16:26:47.500 KotConnect[40258:1345011] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIView 0x7fbfe3c0a030> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key loadingView.'
*** First throw call stack:
(
    0   CoreFoundation                      0x00000001105ca34b __exceptionPreprocess + 171
    1   libobjc.A.dylib                     0x000000011002b21e objc_exception_throw + 48
    2   CoreFoundation                      0x00000001105ca299 -[NSException raise] + 9
    3   Foundation                          0x000000010fb3b26f -[NSObject(NSKeyValueCoding) setValue:forKey:] + 291
    4   UIKit                               0x0000000110e0580d -[UIView(CALayerDelegate) setValue:forKey:] + 173
    5   UIKit                               0x000000011114f79e -[UIRuntimeOutletConnection connect] + 109
    6   CoreFoundation                      0x000000011056f590 -[NSArray makeObjectsPerformSelector:] + 256
    7   UIKit                               0x000000011114e122 -[UINib instantiateWithOwner:options:] + 1867
    8   UIKit                               0x0000000110ee1c21 -[UIViewController _loadViewFromNibNamed:bundle:] + 386
    9   UIKit                               0x0000000110ee2543 -[UIViewController loadView] + 177
    10  UIKit                               0x0000000110ee2878 -[UIViewController loadViewIfRequired] + 201
    11  UIKit                               0x0000000110f2307b -[UINavigationController _layoutViewController:] + 55
    12  UIKit                               0x0000000110f23963 -[UINavigationController _updateScrollViewFromViewController:toViewController:] + 471
    13  UIKit                               0x0000000110f23ada -[UINavigationController _startTransition:fromViewController:toViewController:] + 133
    14  UIKit                               0x0000000110f24ce5 -[UINavigationController _startDeferredTransitionIfNeeded:] + 874
    15  UIKit                               0x0000000110f25dc7 -[UINavigationController __viewWillLayoutSubviews] + 58
    16  UIKit                               0x000000011111cd6f -[UILayoutContainerView layoutSubviews] + 223
    17  UIKit                               0x0000000110e05f50 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1237
    18  QuartzCore                          0x0000000110ac3cc4 -[CALayer layoutSublayers] + 146
    19  QuartzCore                          0x0000000110ab7788 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 366
    20  QuartzCore                          0x0000000110ab7606 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 24
    21  QuartzCore                          0x0000000110a45680 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 280
    22  QuartzCore                          0x0000000110a72767 _ZN2CA11Transaction6commitEv + 475
    23  QuartzCore                          0x0000000110a730d7 _ZN2CA11Transaction17observer_callbackEP19__CFRunLoopObservermPv + 113
    24  CoreFoundation                      0x000000011056ee17 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
    25  CoreFoundation                      0x000000011056ed87 __CFRunLoopDoObservers + 391
    26  CoreFoundation                      0x00000001105534b6 CFRunLoopRunSpecific + 454
    27  UIKit                               0x0000000110d3b7e6 -[UIApplication _run] + 434
    28  UIKit                               0x0000000110d41964 UIApplicationMain + 159
    29  KotConnect                          0x000000010d52cc8f main + 111
    30  libdyld.dylib                       0x00000001135c968d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb) 

推荐答案

Swift

只需添加

NSSetUncaughtExceptionHandler { exception in
   print(exception)
   print(exception.callStackSymbols)
}

位于 AppDelegate didFinishLaunchingWithOptions 方法底部.它将为您提供有关发生的例外的更好信息. 编码愉快!

at the bottom of didFinishLaunchingWithOptions method of AppDelegate. It will give you the better info about the exception occurred. Happy coding !

这篇关于如何调试:libc ++ abi.dylib:以NSException类型的未捕获异常终止?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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