启动后app崩溃,日志无信息,于是使用lldb的waitfor调试,得到崩溃点
* thread #1, queue = 'com.apple.main-thread', stop reason = signal SIGABRT
* frame #0: 0x00000001f91ff0dc libsystem_kernel.dylib`__pthread_kill + 8
frame #1: 0x00000001f9278094 libsystem_pthread.dylib`pthread_kill$VARIANT$mp + 380
frame #2: 0x00000001f9157ea8 libsystem_c.dylib`abort + 140
frame #3: 0x00000001f8824788 libc++abi.dylib`abort_message + 132
frame #4: 0x00000001f8824934 libc++abi.dylib`default_terminate_handler() + 308
frame #5: 0x00000001f883be00 libobjc.A.dylib`_objc_terminate() + 124
frame #6: 0x00000001f8830838 libc++abi.dylib`std::__terminate(void (*)()) + 16
frame #7: 0x00000001f88308c4 libc++abi.dylib`std::terminate() + 84
frame #8: 0x00000001f883bd5c libobjc.A.dylib`objc_terminate + 12
frame #9: 0x00000001f90a17e8 libdispatch.dylib`_dispatch_client_callout + 36
frame #10: 0x00000001f90465dc libdispatch.dylib`_dispatch_block_invoke_direct$VARIANT$mp + 224
frame #11: 0x00000001fc01a040 FrontBoardServices`__FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 40
frame #12: 0x00000001fc019cdc FrontBoardServices`-[FBSSerialQueue _performNext] + 408
frame #13: 0x00000001fc01a294 FrontBoardServices`-[FBSSerialQueue _performNextFromRunLoopSource] + 52
frame #14: 0x00000001f95f4f1c CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
frame #15: 0x00000001f95f4e9c CoreFoundation`__CFRunLoopDoSource0 + 88
frame #16: 0x00000001f95f4784 CoreFoundation`__CFRunLoopDoSources0 + 176
frame #17: 0x00000001f95ef6c0 CoreFoundation`__CFRunLoopRun + 1004
frame #18: 0x00000001f95eefb4 CoreFoundation`CFRunLoopRunSpecific + 436
frame #19: 0x00000001fb7f079c GraphicsServices`GSEventRunModal + 104
frame #20: 0x0000000225e50c38 UIKitCore`UIApplicationMain + 212
frame #21: 0x0000000104280f98 ALS.dylib`___lldb_unnamed_symbol4$$ALS.dylib + 400
frame #22: 0x0000000100b99d44 g37`___lldb_unnamed_symbol22358$$g37 + 92
frame #23: 0x000000010073ffd8 g37`___lldb_unnamed_symbol151$$g37 + 376
frame #24: 0x00000001f90b28e0 libdyld.dylib`start + 4
从此崩溃点可知是c++异常,但由于使用dispatch无法看到错误来源,于是根据objc_terminate,在下次启动断在objc_exception_throw,得到结果:
* thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 2.1
* frame #0: 0x00000001f883b9c0 libobjc.A.dylib`objc_exception_throw
frame #1: 0x00000001f957f9bc CoreFoundation`-[NSObject(NSObject) doesNotRecognizeSelector:] + 140
frame #2: 0x00000001f96689c8 CoreFoundation`___forwarding___ + 1408
frame #3: 0x00000001f966a65c CoreFoundation`_CF_forwarding_prep_0 + 92
frame #4: 0x00000001018bd1b8 g37`___lldb_unnamed_symbol71594$$g37 + 48
frame #5: 0x00000001018bdf18 g37`___lldb_unnamed_symbol71609$$g37 + 216
frame #6: 0x00000001018bddf4 g37`___lldb_unnamed_symbol71608$$g37 + 260
frame #7: 0x00000001018c050c g37`___lldb_unnamed_symbol71621$$g37 + 132
frame #8: 0x00000001018c09c8 g37`___lldb_unnamed_symbol71623$$g37 + 96
frame #9: 0x00000001018bd11c g37`___lldb_unnamed_symbol71593$$g37 + 132
frame #10: 0x00000001018c70e4 g37`___lldb_unnamed_symbol71782$$g37 + 1588
frame #11: 0x00000001018c75ec g37`___lldb_unnamed_symbol71788$$g37 + 32
frame #12: 0x00000001018e33d8 g37`___lldb_unnamed_symbol72456$$g37 + 196
frame #13: 0x00000001f954c54c CoreFoundation`-[__NSArrayM enumerateObjectsWithOptions:usingBlock:] + 216
frame #14: 0x00000001018e318c g37`___lldb_unnamed_symbol72455$$g37 + 656
frame #15: 0x00000001018f0b44 g37`___lldb_unnamed_symbol72812$$g37 + 44
frame #16: 0x00000001018f0e1c g37`___lldb_unnamed_symbol72813$$g37 + 576
frame #17: 0x0000000100adae64 g37`___lldb_unnamed_symbol22547$$g37 + 796
frame #18: 0x00000001043dd638 ALS.dylib`___lldb_unnamed_symbol12$$ALS.dylib + 796
frame #19: 0x0000000225e480f0 UIKitCore`-[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:] + 412
frame #20: 0x0000000225e49854 UIKitCore`-[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 3352
frame #21: 0x0000000225e4efe0 UIKitCore`-[UIApplication _runWithMainScene:transitionContext:completion:] + 1540
frame #22: 0x00000002257122a4 UIKitCore`__111-[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:]_block_invoke + 776
frame #23: 0x000000022571a83c UIKitCore`+[_UICanvas _enqueuePostSettingUpdateTransactionBlock:] + 160
frame #24: 0x0000000225711f28 UIKitCore`-[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:] + 236
frame #25: 0x0000000225712818 UIKitCore`-[__UICanvasLifecycleMonitor_Compatability activateEventsOnly:withContext:completion:] + 1064
frame #26: 0x0000000225710b64 UIKitCore`__82-[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:]_block_invoke + 744
frame #27: 0x000000022571082c UIKitCore`-[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:] + 428
frame #28: 0x000000022571536c UIKitCore`__125-[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:]_block_invoke + 220
frame #29: 0x0000000225716150 UIKitCore`_performActionsWithDelayForTransitionContext + 112
frame #30: 0x0000000225715224 UIKitCore`-[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:] + 244
frame #31: 0x0000000225719f24 UIKitCore`-[_UICanvas scene:didUpdateWithDiff:transitionContext:completion:] + 360
frame #32: 0x0000000225e4d5e8 UIKitCore`-[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 540
frame #33: 0x0000000225a49e04 UIKitCore`-[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 360
frame #34: 0x00000001fbfdf9fc FrontBoardServices`-[FBSSceneImpl _didCreateWithTransitionContext:completion:] + 440
frame #35: 0x00000001fbfe940c FrontBoardServices`__56-[FBSWorkspace client:handleCreateScene:withCompletion:]_block_invoke_2 + 256
frame #36: 0x00000001fbfe8c14 FrontBoardServices`__40-[FBSWorkspace _performDelegateCallOut:]_block_invoke + 64
frame #37: 0x00000001f90a17d4 libdispatch.dylib`_dispatch_client_callout + 16
frame #38: 0x00000001f90465dc libdispatch.dylib`_dispatch_block_invoke_direct$VARIANT$mp + 224
frame #39: 0x00000001fc01a040 FrontBoardServices`__FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 40
frame #40: 0x00000001fc019cdc FrontBoardServices`-[FBSSerialQueue _performNext] + 408
frame #41: 0x00000001fc01a294 FrontBoardServices`-[FBSSerialQueue _performNextFromRunLoopSource] + 52
frame #42: 0x00000001f95f4f1c CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
frame #43: 0x00000001f95f4e9c CoreFoundation`__CFRunLoopDoSource0 + 88
frame #44: 0x00000001f95f4784 CoreFoundation`__CFRunLoopDoSources0 + 176
frame #45: 0x00000001f95ef6c0 CoreFoundation`__CFRunLoopRun + 1004
frame #46: 0x00000001f95eefb4 CoreFoundation`CFRunLoopRunSpecific + 436
frame #47: 0x00000001fb7f079c GraphicsServices`GSEventRunModal + 104
frame #48: 0x0000000225e50c38 UIKitCore`UIApplicationMain + 212
frame #49: 0x00000001043dcf98 ALS.dylib`___lldb_unnamed_symbol4$$ALS.dylib + 400
frame #50: 0x0000000100ad1d44 g37`___lldb_unnamed_symbol22358$$g37 + 92
frame #51: 0x0000000100677fd8 g37`___lldb_unnamed_symbol151$$g37 + 376
frame #52: 0x00000001f90b28e0 libdyld.dylib`start + 4
这次可以看到,由于没找到selector导致异常。
一般的,selector找不到的错误,可以在系统日志查到,但是有些机器上不显示,只能这么手动找了