没有网络连接时,iOS应用程序在启动时崩溃

时间:2019-03-21 16:07:12

标签: ios swift networking crash nib

正如标题所述,如果没有打开互联网连接/飞行模式,我的应用程序将在运行时立即崩溃。关键是,当我设置断点时,它甚至都没有进入我的任何代码。没有调用单个viewDidLoad甚至AppDelegate函数,并且错误消息似乎与没有网络连接有关:

  

2019-03-21 10:30:20.193955-0500 AppName [98957:977030] ***终止   应用由于未捕获的异常“ NSInternalInconsistencyException”而导致   原因:“无法在捆绑包中加载NIB:” NSBundle   (已加载)',名称为   'BYZ-38-t0r-view-8bC-Xf-vdC''

(出于隐私考虑,我显然在其中插入了一些假值)

调用堆栈:

*** First throw call stack:
(
0   CoreFoundation                      0x00000001036cb1bb __exceptionPreprocess + 331
1   libobjc.A.dylib                     0x0000000102c69735 objc_exception_throw + 48
2   CoreFoundation                      0x00000001036cb015 +[NSException raise:format:] + 197
3   UIKitCore                           0x00000001088edd94 -[UINib instantiateWithOwner:options:] + 497
4   UIKitCore                           0x0000000108661452 -[UIViewController _loadViewFromNibNamed:bundle:] + 383
5   UIKitCore                           0x0000000108661ddc -[UIViewController loadView] + 177
6   UIKitCore                           0x00000001086620ee -[UIViewController loadViewIfRequired] + 175
7   UIKitCore                           0x0000000108662940 -[UIViewController view] + 27
8   UIKitCore                           0x000000010858134c -[UIPresentationController __sizeClassPair] + 62
9   UIKitCore                           0x0000000108675428 -[UIViewController _presentViewController:withAnimationController:completion:] + 2300
10  UIKitCore                           0x000000010867874b __63-[UIViewController _presentViewController:animated:completion:]_block_invoke + 99
11  UIKitCore                           0x0000000108678dd9 -[UIViewController _performCoordinatedPresentOrDismiss:animated:] + 511
12  UIKitCore                           0x00000001086786b1 -[UIViewController _presentViewController:animated:completion:] + 173
13  UIKitCore                           0x00000001086789f0 -[UIViewController presentViewController:animated:completion:] + 150
14  AppName                        0x0000000100f1125e $SSo16UIViewControllerC12DataScoutProE27showDismissiveAlertMesssage7messageySS_tF + 254
15  AppName                        0x0000000100e58a97 $S12AppName18HomeViewControllerC10commonInit33_90D4AB13D5DB6EAFA2D0742F81F552BALLyyF + 727
16  AppName                        0x0000000100e58462 $S12AppName18HomeViewControllerC5coderACSgSo7NSCoderC_tcfc + 146
17  AppName                        0x0000000100e584df $S12AppName18HomeViewControllerC5coderACSgSo7NSCoderC_tcfcTo + 47
18  UIKitCore                           0x00000001088ec166 -[UIClassSwapper initWithCoder:] + 246
19  UIFoundation                        0x000000010c8f35ad UINibDecoderDecodeObjectForValue + 749
20  UIFoundation                        0x000000010c8f32b3 -[UINibDecoder decodeObjectForKey:] + 251
21  UIKitCore                           0x00000001088f07b8 -[UIRuntimeConnection initWithCoder:] + 178
22  UIFoundation                        0x000000010c8f35ad UINibDecoderDecodeObjectForValue + 749
23  UIFoundation                        0x000000010c8f3854 UINibDecoderDecodeObjectForValue + 1428
24  UIFoundation                        0x000000010c8f32b3 -[UINibDecoder decodeObjectForKey:] + 251
25  UIKitCore                           0x00000001088ee067 -[UINib instantiateWithOwner:options:] + 1220
26  UIKitCore                           0x0000000108e228b6 -[UIStoryboard instantiateViewControllerWithIdentifier:] + 181
27  UIKitCore                           0x0000000108c8103a -[UIApplication _loadMainStoryboardFileNamed:bundle:] + 112
28  UIKitCore                           0x0000000108c8150c -[UIApplication _loadMainInterfaceFile] + 272
29  UIKitCore                           0x0000000108c7fb25 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1357
30  UIKitCore                           0x000000010849e4e9 __111-[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:]_block_invoke + 866
31  UIKitCore                           0x00000001084a729c +[_UICanvas _enqueuePostSettingUpdateTransactionBlock:] + 153
32  UIKitCore                           0x000000010849e126 -[__UICanvasLifecycleMonitor_Compatability _scheduleFirstCommitForScene:transition:firstActivation:completion:] + 233
33  UIKitCore                           0x000000010849eae0 -[__UICanvasLifecycleMonitor_Compatability activateEventsOnly:withContext:completion:] + 1085
34  UIKitCore                           0x000000010849ccb5 __82-[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:]_block_invoke + 795
35  UIKitCore                           0x000000010849c95f -[_UIApplicationCanvas _transitionLifecycleStateWithTransitionContext:completion:] + 435
36  UIKitCore                           0x00000001084a1a90 __125-[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:]_block_invoke + 584
37  UIKitCore                           0x00000001084a280e _performActionsWithDelayForTransitionContext + 100
38  UIKitCore                           0x00000001084a17ef -[_UICanvasLifecycleSettingsDiffAction performActionsForCanvas:withUpdatedScene:settingsDiff:fromSettings:transitionContext:] + 221
39  UIKitCore                           0x00000001084a693a -[_UICanvas scene:didUpdateWithDiff:transitionContext:completion:] + 392
40  UIKitCore                           0x0000000108c7e44e -[UIApplication workspace:didCreateScene:withTransitionContext:completion:] + 515
41  UIKitCore                           0x0000000108822d09 -[UIApplicationSceneClientAgent scene:didInitializeWithEvent:completion:] + 357
42  FrontBoardServices                  0x000000010f55e2da -[FBSSceneImpl _didCreateWithTransitionContext:completion:] + 448
43  FrontBoardServices                  0x000000010f569443 __56-[FBSWorkspace client:handleCreateScene:withCompletion:]_block_invoke_2 + 271
44  FrontBoardServices                  0x000000010f568b3a __40-[FBSWorkspace _performDelegateCallOut:]_block_invoke + 53
45  libdispatch.dylib                   0x000000010548a602 _dispatch_client_callout + 8
46  libdispatch.dylib                   0x000000010548db78 _dispatch_block_invoke_direct + 301
47  FrontBoardServices                  0x000000010f59dba8 __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__ + 30
48  FrontBoardServices                  0x000000010f59d860 -[FBSSerialQueue _performNext] + 457
49  FrontBoardServices                  0x000000010f59de40 -[FBSSerialQueue _performNextFromRunLoopSource] + 45
50  CoreFoundation                      0x0000000103630721 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
51  CoreFoundation                      0x000000010362ff93 __CFRunLoopDoSources0 + 243
52  CoreFoundation                      0x000000010362a63f __CFRunLoopRun + 1263
53  CoreFoundation                      0x0000000103629e11 CFRunLoopRunSpecific + 625
54  GraphicsServices                    0x000000010c5b71dd GSEventRunModal + 62
55  UIKitCore                           0x0000000108c8181d UIApplicationMain + 140
56  AppName                        0x0000000100e8e794 main + 68
57  libdyld.dylib                       0x0000000105500575 start + 1
)

我真的不知道这可能是什么。尝试在[UIViewController _loadViewFromNibNamed:bundle:]上设置一个符号断点,但实际上并没有提供任何有用的见解。希望有人能帮忙。我还应该提到我在AppDelegate中唯一要做的是实例化Firebase。

1 个答案:

答案 0 :(得分:0)

reddit上的一位乐于助人的家伙为我解决了这个问题。没意识到,但是我最初的视图控制器上有一个init()函数,最后一个家伙做了这个,它检查了互联网连接,如果没有,则重定向到另一个页面。