XCode:ios 9-10 与 ios 11 上的 NSException 类型的未捕获异常
XCode: uncaught exception of type NSException on ios 9-10 vs ios 11
我注意到当应用程序在 iOS 11 崩溃时,一些异常,如 NSGenericException 或 NSManagedObject Exceptions 在输出中不包含很多细节。但同时如果我 运行 和让它在 iOS 9 或 10 崩溃,它将包含很多有用的细节。
例如。同样的应用程序,同样的崩溃,在 iOS 11:
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
在 iOS 9-10:
2018-01-02 23:51:22.967 CafeManager[3726:130232] *** Terminating app due to uncaught exception 'NSGenericException', reason: 'Your application has presented a UIAlertController (<UIAlertController: 0x7f959a7634c0>) of style UIAlertControllerStyleActionSheet. The modalPresentationStyle of a UIAlertController with this style is UIModalPresentationPopover. You must provide location information for this popover through the alert controller's popoverPresentationController. You must provide either a sourceView and sourceRect or a barButtonItem. If this information is not known when you present the alert controller, you may provide it in the UIPopoverPresentationControllerDelegate method -prepareForPopoverPresentation.'
*** First throw call stack:
(
0 CoreFoundation 0x000000010f61eb0b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010ec6f141 objc_exception_throw + 48
2 UIKit 0x0000000110c04d67 -[UIPopoverPresentationController presentationTransitionWillBegin] + 3291
3 UIKit 0x00000001102ac3c2 __71-[UIPresentationController _initViewHierarchyForPresentationSuperview:]_block_invoke + 2278
4 UIKit 0x00000001102a9d20 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 426
5 UIKit 0x0000000110137853 _runAfterCACommitDeferredBlocks + 318
6 UIKit 0x000000011012481c _cleanUpAfterCAFlushAndRunDeferredBlocks + 532
7 UIKit 0x0000000110156560 _afterCACommitHandler + 137
8 CoreFoundation 0x000000010f5c4717 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
9 CoreFoundation 0x000000010f5c4687 __CFRunLoopDoObservers + 391
10 CoreFoundation 0x000000010f5a9720 __CFRunLoopRun + 1200
11 CoreFoundation 0x000000010f5a9016 CFRunLoopRunSpecific + 406
12 GraphicsServices 0x0000000114cc1a24 GSEventRunModal + 62
13 UIKit 0x000000011012b134 UIApplicationMain + 159
14 CafeManager 0x000000010dd37747 main + 55
15 libdyld.dylib 0x0000000113d1c65d start + 1
16 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
如您所见,它确实有所作为。我错过了什么?任何调试器设置还是与 iOS 11 相关的问题?
更新:
在 Apple Developer Forums 和 Apple Bug reporter 上提出了同样的问题。暂时没有答案。
您是否偶然设置了 OS_ACTIVITY_MODE 变量?
要检查您是否设置了此变量(并将其关闭),请在 Xcode 9 中执行以下操作:
Select 来自 Xcode 菜单产品 -> 方案 -> 编辑方案..
Select 运行 方案并查看参数。
如果您看到 OS_ACTIVITY_MODE 变量被选中,请取消选择它。
我注意到当应用程序在 iOS 11 崩溃时,一些异常,如 NSGenericException 或 NSManagedObject Exceptions 在输出中不包含很多细节。但同时如果我 运行 和让它在 iOS 9 或 10 崩溃,它将包含很多有用的细节。
例如。同样的应用程序,同样的崩溃,在 iOS 11:
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
在 iOS 9-10:
2018-01-02 23:51:22.967 CafeManager[3726:130232] *** Terminating app due to uncaught exception 'NSGenericException', reason: 'Your application has presented a UIAlertController (<UIAlertController: 0x7f959a7634c0>) of style UIAlertControllerStyleActionSheet. The modalPresentationStyle of a UIAlertController with this style is UIModalPresentationPopover. You must provide location information for this popover through the alert controller's popoverPresentationController. You must provide either a sourceView and sourceRect or a barButtonItem. If this information is not known when you present the alert controller, you may provide it in the UIPopoverPresentationControllerDelegate method -prepareForPopoverPresentation.'
*** First throw call stack:
(
0 CoreFoundation 0x000000010f61eb0b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010ec6f141 objc_exception_throw + 48
2 UIKit 0x0000000110c04d67 -[UIPopoverPresentationController presentationTransitionWillBegin] + 3291
3 UIKit 0x00000001102ac3c2 __71-[UIPresentationController _initViewHierarchyForPresentationSuperview:]_block_invoke + 2278
4 UIKit 0x00000001102a9d20 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 426
5 UIKit 0x0000000110137853 _runAfterCACommitDeferredBlocks + 318
6 UIKit 0x000000011012481c _cleanUpAfterCAFlushAndRunDeferredBlocks + 532
7 UIKit 0x0000000110156560 _afterCACommitHandler + 137
8 CoreFoundation 0x000000010f5c4717 __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 23
9 CoreFoundation 0x000000010f5c4687 __CFRunLoopDoObservers + 391
10 CoreFoundation 0x000000010f5a9720 __CFRunLoopRun + 1200
11 CoreFoundation 0x000000010f5a9016 CFRunLoopRunSpecific + 406
12 GraphicsServices 0x0000000114cc1a24 GSEventRunModal + 62
13 UIKit 0x000000011012b134 UIApplicationMain + 159
14 CafeManager 0x000000010dd37747 main + 55
15 libdyld.dylib 0x0000000113d1c65d start + 1
16 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
(lldb)
如您所见,它确实有所作为。我错过了什么?任何调试器设置还是与 iOS 11 相关的问题?
更新: 在 Apple Developer Forums 和 Apple Bug reporter 上提出了同样的问题。暂时没有答案。
您是否偶然设置了 OS_ACTIVITY_MODE 变量?
要检查您是否设置了此变量(并将其关闭),请在 Xcode 9 中执行以下操作:
Select 来自 Xcode 菜单产品 -> 方案 -> 编辑方案.. Select 运行 方案并查看参数。 如果您看到 OS_ACTIVITY_MODE 变量被选中,请取消选择它。