添加异常断点会导致崩溃而没有堆栈跟踪

时间:2017-10-30 18:51:03

标签: xcode

我正在开发一个尚未使用Xcode 9转换到Swift 4的应用程序。我发现了一个崩溃并意识到调试器没有打印出导致崩溃的线路,也没有原因在它背后。它只打印出一个NSException。

我开始深入研究为什么会发生这种情况,并发现我应该尝试添加异常断点。但是,每当我尝试这样做时,应用程序会在加载时崩溃,即使是第一次安装时也是如此。然而,当我禁用断点时,应用程序工作正常并且不会崩溃。我不确定Xcode何时停止打印描述性堆栈跟踪,因为这不是过去发生的事情,而是最近的更改。

我已经查看了我的计划,我已经添加了po $ arg1,po $ eax并直接尝试获取po [$ arg1 reason]& [$ arg1 name]。我不确定该怎么做以及如何让它再次工作......任何想法为什么会发生这种情况?

编辑:通过键入" bt"最终能够打印出栈跟踪。下一个(lldb),这就是我得到的。但我不知道它意味着什么,它并没有指向特定的代码行。

thread #1, queue = 'com.apple.main-thread', stop reason = breakpoint 1.2
frame #0: 0x0000000180757e20 libc++abi.dylib`__cxa_throw
frame #1: 0x00000001848e0cb8 libFontParser.dylib`TFileDescriptorContext::TFileDescriptorContext(char const*) + 156
frame #2: 0x00000001849082e4 libFontParser.dylib`TFileDataReference::MapOrRead(char const*, int) + 40
frame #3: 0x00000001848e0ae8 libFontParser.dylib`TFileDataReference::TFileDataReference(char const*) + 
frame #4: 0x00000001848e08f8 libFontParser.dylib`TFileDataSurrogate::TFileDataSurrogate(char const*, bool) + 156
frame #5: 0x00000001849273ec libFontParser.dylib`TFont::CreateFontEntities(char const*, bool, bool&, short, char const*, bool) + 268
frame #6: 0x0000000184928a40 libFontParser.dylib`TFont::CreateFontEntitiesForFile(char const*, bool, bool, short, char const*) + 220
frame #7: 0x00000001848e0364 libFontParser.dylib`FPFontCreateFontsWithPath + 152
frame #8: 0x0000000182cb1fe4 CoreGraphics`create_private_data_array_with_path + 48
frame #9: 0x00000001829f5bd8 CoreGraphics`CGFontCreateFontsWithPath + 36
frame #10: 0x0000000182a45084 CoreGraphics`CGFontCreateFontsWithURL + 372
frame #11: 0x0000000182fa2fc0 GraphicsServices`AddFontsFromURLOrPath + 124
frame #12: 0x0000000182fa663c GraphicsServices`__Initialize_block_invoke + 1020
frame #13: 0x0000000103e1945c libdispatch.dylib`_dispatch_client_callout + 16
frame #14: 0x0000000103e1a17c libdispatch.dylib`dispatch_once_f + 120
frame #15: 0x0000000182fa2ae4 GraphicsServices`Initialize + 272
frame #16: 0x000000018076943c libobjc.A.dylib`CALLING_SOME_+initialize_METHOD + 24
frame #17: 0x0000000180769804 libobjc.A.dylib`_class_initialize + 296
frame #18: 0x0000000180771744 libobjc.A.dylib`lookUpImpOrForward + 228
frame #19: 0x000000018077c758 libobjc.A.dylib`_objc_msgSend_uncached + 56
frame #20: 0x000000018b36ee54 UIKit`-[UIStatusBarForegroundStyleAttributes makeTextFontForStyle:] + 152
frame #21: 0x000000018a6ad3f8 UIKit`-[UIStatusBarForegroundStyleAttributes textFontForStyle:] + 124
frame #22: 0x000000018b36e95c UIKit`-[UIStatusBarForegroundStyleAttributes imageWithText:ofItemType:forWidth:lineBreakMode:letterSpacing:textAlignment:style:withLegibilityStyle:legibilityStrength:] + 312
frame #23: 0x000000018a6ad278 UIKit`-[UIStatusBarItemView imageWithText:] + 260
frame #24: 0x000000018a6ad0cc UIKit`-[UIStatusBarItemView updateContentsAndWidth] + 36
frame #25: 0x000000018a6ba2f0 UIKit`-[UIStatusBarItemView initWithItem:data:actions:style:] + 432
frame #26: 0x000000018a6ba0a8 UIKit`+[UIStatusBarItemView createViewForItem:withData:actions:foregroundStyle:] + 132
frame #27: 0x000000018a6b9f2c UIKit`-[UIStatusBarLayoutManager _createViewForItem:withData:actions:] + 172
frame #28: 0x000000018a6595e4 UIKit`-[UIStatusBarLayoutManager _prepareEnabledItemType:withEnabledItems:withData:actions:itemAppearing:itemDisappearing:] + 332
frame #29: 0x000000018a659420 UIKit`-[UIStatusBarLayoutManager prepareEnabledItems:withData:actions:] + 108
frame #30: 0x000000018a6590d8 UIKit`-[UIStatusBarForegroundView _setStatusBarData:actions:animated:] + 544
frame #31: 0x000000018a658d9c UIKit`-[UIStatusBarForegroundView setStatusBarData:actions:animated:] + 1196
frame #32: 0x000000018ad0ad20 UIKit`__51-[UIStatusBar _prepareToSetStyle:animation:forced:]_block_invoke + 356
frame #33: 0x000000018a671a84 UIKit`+[UIView(Animation) performWithoutAnimation:] + 104
frame #34: 0x000000018ad0a7ac UIKit`-[UIStatusBar _prepareToSetStyle:animation:forced:] + 836
frame #35: 0x000000018ad09748 UIKit`-[UIStatusBar _updateUIWithStyleAttributes:animationParameters:forced:] + 560
frame #36: 0x000000018ad09368 UIKit`-[UIStatusBar _requestStyle:animationParameters:forced:] + 520
frame #37: 0x000000018ae39430 UIKit`-[UIStatusBar_Base requestStyle:animationParameters:forced:] + 96
frame #38: 0x000000018a6e8758 UIKit`-[UIApplication _setStatusBarStyle:animationParameters:] + 168
frame #39: 0x000000018a66aaa8 UIKit`-[UIApplication _updateCurrentStatusBarViewControllerAppearance] + 276
frame #40: 0x000000018a91a7b0 UIKit`-[UIWindow _updateLayerOrderingAndSetLayerHidden:] + 616
frame #41: 0x000000018a6675dc UIKit`-[UIWindow _setHidden:forced:] + 228
frame #42: 0x000000018a6cde98 UIKit`-[UIApplication _createStatusBarWithRequestedStyle:orientation:hidden:] + 664
frame #43: 0x000000018a8cb430 UIKit`-[UIApplication _runWithMainScene:transitionContext:completion:] + 1020
frame #44: 0x000000018ab59454 UIKit`__111-[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:]_block_invoke + 800
frame #45: 0x000000018ae291f0 UIKit`+[_UICanvas _enqueuePostSettingUpdateTransactionBlock:] + 160
frame #46: 0x000000018ab590b8 UIKit`-[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:] + 252
frame #47: 0x000000018ab59928 UIKit`-[__UICanvasLifecycleMonitor_Compatability activateEventsOnly:withContext:completion:] + 748
frame #48: 0x000000018b2c26e8 UIKit`__82-[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:]_block_invoke + 260
frame #49: 0x000000018b2c258c UIKit`-[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:] + 448
frame #50: 0x000000018b03e9c0 UIKit`__125-[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:]_block_invoke + 220
frame #51: 0x000000018b1d3fc8 UIKit`_performActionsWithDelayForTransitionContext + 112
frame #52: 0x000000018b03e870 UIKit`-[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:] + 252
frame #53: 0x000000018ae28850 UIKit`-[_UICanvas scene:didUpdateWithDiff:transitionContext:completion:] + 364
frame #54: 0x000000018a8c9e28 UIKit`-[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 540
frame #55: 0x000000018accd6ec UIKit`-[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 364
frame #56: 0x00000001838f5768 FrontBoardServices`-[FBSSceneImpl _didCreateWithTransitionContext:completion:] + 364
frame #57: 0x00000001838fe070 FrontBoardServices`__56-[FBSWorkspace client:handleCreateScene:withCompletion:]_block_invoke_2 + 224
frame #58: 0x0000000103e1945c libdispatch.dylib`_dispatch_client_callout + 16
frame #59: 0x0000000103e25b74 libdispatch.dylib`_dispatch_block_invoke_direct + 268
frame #60: 0x0000000183929a04 FrontBoardServices`__FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 36
frame #61: 0x00000001839296a8 FrontBoardServices`-[FBSSerialQueue _performNext] + 404
frame #62: 0x0000000183929c44 FrontBoardServices`-[FBSSerialQueue _performNextFromRunLoopSource] + 56
frame #63: 0x00000001811fc358 CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 24
frame #64: 0x00000001811fc2d8 CoreFoundation`__CFRunLoopDoSource0 + 88
frame #65: 0x00000001811fbb60 CoreFoundation`__CFRunLoopDoSources0 + 204
frame #66: 0x00000001811f9738 CoreFoundation`__CFRunLoopRun + 1048
frame #67: 0x000000018111a2d8 CoreFoundation`CFRunLoopRunSpecific + 436
frame #68: 0x0000000182fabf84 GraphicsServices`GSEventRunModal + 100
frame #69: 0x000000018a6c7880 UIKit`UIApplicationMain + 208
frame #70: 0x000000010066ffc0 AppName`main at AppDelegate.swift:21
frame #71: 0x0000000180c3e56c libdyld.dylib`start + 4

1 个答案:

答案 0 :(得分:3)

免责声明:此修复仅适用于故事板中不使用自定义字体(即系统以外的字体)的情况。如果您的故事板中有自定义字体,那么我不确定问题是什么。就我而言,这是一次意外。

通过从故事板中删除自定义字体进行修复:

我在Xcode 9中打开了我的故事板以进行一些更改。然后我运行了应用程序,然后......崩溃! (甚至没有到达第一个视图控制器。)我注意到堆栈跟踪中有关Font的奇怪内容(类似于上面问题中的堆栈跟踪)。

然后我查看了我的故事板的XML文件(我刚用vim而不是Xcode打开故事板)并注意到这个块靠近顶部:

<customFonts key="customFonts">
    <array key="HelveticaNeue.ttc">
        <string>HelveticaNeue</string>
    </array>
</customFonts>

当我在Xcode 9中打开故事板时,会自动添加此块,因为显然我使用的是某些标签的自定义字体。

为了解决这个问题,我在Xcode中打开了故事板并搜索了“helv”以找到我不小心使用HelveticaNeue作为字体而不是System的所有标签。更改所有这些标签以使用System还会导致Xcode自动删除导致崩溃的XML块。

希望这有助于某人!