Search code examples
iosios11xcode9

migrated project from xcode 8 to xcode 9 crash on launcher screen


Everything was working fine on xcode 7.3.1, Than I have to add braintree 3ds sdk which is supported on xcode 8. So, I migrated the code to xcode 8 and than xcode 9. Now, build working fine on below IOS 11 but on ios 11 and above app is crashing before opening new main screen. I am new to Ios please help.

it's crashing on this line :

let vc = storyboard?.instantiateViewController(withIdentifier: "KbNav") as! KabNavigationController

2018-08-30 12:25:52.730641+0500 Kab[2970:32711] *** Assertion failure in 
-[_UINavigationBarVisualProviderModernIOS _contentViewFittingHeight], 
 /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKit_Sim/UIKit- 
 3698.33.6/_UINavigationBarVisualProviderModernIOS.m:569
 2018-08-30 12:25:52.769549+0500 Kab[2970:32711] *** Terminating app due 
 to uncaught exception 'NSInternalInconsistencyException', reason: 'Sigh. 
 Contentview size is zero.'
 *** First throw call stack:
 (
0   CoreFoundation                      0x0000000115da712b __exceptionPreprocess + 171
1   libobjc.A.dylib                     0x0000000114d50f41 objc_exception_throw + 48
2   CoreFoundation                      0x0000000115dac2f2 +[NSException raise:format:arguments:] + 98
3   Foundation                          0x00000001147f1d69 -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] + 193
4   UIKit                               0x00000001131382f5 -[_UINavigationBarVisualProviderModernIOS _contentViewFittingHeight] + 265
5   UIKit                               0x0000000112eb65e0 -[UINavigationItem _desiredHeightForBarMetrics:defaultHeightBlock:] + 90
6   UIKit                               0x000000011313afa1 -[_UINavigationBarVisualProviderModernIOS heightRangeFittingWidth:] + 412
7   UIKit                               0x000000011264a0ed -[UINavigationBar _heightRangeForNavigationItem:fittingWidth:] + 210
8   UIKit                               0x0000000112726a98 -[UINavigationController _intrinsicNavigationBarHeightRangeForViewController:] + 187
9   UIKit                               0x00000001127269b6 -[UINavigationController _preferredHeightForHidingNavigationBarForViewController:] + 628
10  UIKit                               0x000000011271688f -[UINavigationController _positionNavigationBarHidden:edge:initialOffset:] + 356
11  UIKit                               0x0000000112716cf8 -[UINavigationController _positionNavigationBarHidden:edge:] + 388
12  UIKit                               0x000000011271e555 -[UINavigationController loadView] + 243
13  UIKit                               0x00000001126e105c -[UIViewController loadViewIfRequired] + 195
14  UIKit                               0x00000001126e18b9 -[UIViewController view] + 27
15  Kab                           0x000000010f00faea -[SlideNavigationController setEnableShadow:] + 74
16  Kab                           0x000000010f00d494 -[SlideNavigationController setup] + 244
17  Kab                            0x000000010f00d1d1 -[SlideNavigationController initWithCoder:] + 145
18  Kab                            0x000000010f20e1d6 _T08Kab0A20NavigationControllerCACSgSo7NSCoderC5coder_tcfc + 214
19  Kab                           0x000000010f20e29f _T08Kab0A20NavigationControllerCACSgSo7NSCoderC5coder_tcfcTo + 47
20  UIKit                               0x00000001129ca4c8 -[UIClassSwapper initWithCoder:] + 246
21  UIKit                               0x0000000112c1f109 UINibDecoderDecodeObjectForValue + 704
22  UIKit                               0x0000000112c1ee3e -[UINibDecoder decodeObjectForKey:] + 89
23  UIKit                               0x000000011264675a -[UINavigationBar initWithCoder:] + 753
24  UIKit                               0x0000000112c1f109 UINibDecoderDecodeObjectForValue + 704
25  UIKit                               0x0000000112c1ee3e -[UINibDecoder decodeObjectForKey:] + 89
26  UIKit                               0x0000000112eb15f2 -[UINavigationItem initWithCoder:] + 1018
27  UIKit                               0x0000000112c1f109 UINibDecoderDecodeObjectForValue + 704
28  UIKit                               0x0000000112c1ee3e -[UINibDecoder decodeObjectForKey:] + 89
29  UIKit                               0x00000001126dc053 -[UIViewController initWithCoder:] + 432
30  Kab                           0x000000010f29a6a8 _T08Kab18HomeViewControllerCACSgSo7NSCoderC5coder_tcfc + 7704
31  Kab                           0x000000010f29a77f _T08Kab18HomeViewControllerCACSgSo7NSCoderC5coder_tcfcTo + 47
32  UIKit                               0x00000001129ca4c8 -[UIClassSwapper initWithCoder:] + 246
33  UIKit                               0x0000000112c1f109 UINibDecoderDecodeObjectForValue + 704
34  UIKit                               0x0000000112c1ee3e -[UINibDecoder decodeObjectForKey:] + 89
35  UIKit                               0x00000001129ca194 -[UIRuntimeConnection initWithCoder:] + 178
36  UIKit                               0x00000001129ca8d0 -[UIRuntimeEventConnection initWithCoder:] + 59
37  UIKit                               0x0000000112c1f109 UINibDecoderDecodeObjectForValue + 704
38  UIKit                               0x0000000112c1f2a7 UINibDecoderDecodeObjectForValue + 1118
39  UIKit                               0x0000000112c1ee3e -[UINibDecoder decodeObjectForKey:] + 89
40  UIKit                               0x00000001129c9391 -[UINib instantiateWithOwner:options:] + 1262
41  UIKit                               0x0000000112e59fc2 -[UIStoryboard instantiateViewControllerWithIdentifier:] + 181
42  Kab                          0x000000010f135a7b _T08Kabr24LaunchTourViewControllerC4skipyyXlF + 219
43  Kab                           0x000000010f136118 _T08Kab24LaunchTourViewControllerC4skipyyXlFTo + 56
44  UIKit                               0x000000011253a972 -[UIApplication sendAction:to:from:forEvent:] + 83
45  UIKit                               0x00000001126b9c3c -[UIControl sendAction:to:forEvent:] + 67
46  UIKit                               0x00000001126b9f59 -[UIControl _sendActionsForEvents:withEvent:] + 450
47  UIKit                               0x00000001126b8e86 -[UIControl touchesEnded:withEvent:] + 618
48  UIKit                               0x00000001125b0807 -[UIWindow _sendTouchesForEvent:] + 2807
49  UIKit                               0x00000001125b1f2a -[UIWindow sendEvent:] + 4124
50  UIKit                               0x0000000112555365 -[UIApplication sendEvent:] + 352
51  UIKit                               0x0000000112ea1a1d __dispatchPreprocessedEventFromEventQueue + 2809
52  UIKit                               0x0000000112ea4672 __handleEventQueueInternal + 5957
53  CoreFoundation                      0x0000000115d4a101 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 17
54  CoreFoundation                      0x0000000115de9f71 __CFRunLoopDoSource0 + 81
55  CoreFoundation                      0x0000000115d2ea19 __CFRunLoopDoSources0 + 185
56  CoreFoundation                      0x0000000115d2dfff __CFRunLoopRun + 1279
57  CoreFoundation                      0x0000000115d2d889 CFRunLoopRunSpecific + 409
58  GraphicsServices                    0x0000000118d049c6 GSEventRunModal + 62
59  UIKit                               0x00000001125395d6 UIApplicationMain + 159
60  Kab                           0x000000010f191137 main + 55
61  libdyld.dylib                       0x0000000117112d81 start + 1
62  ???                                 0x0000000000000001 0x0 + 1
  )
       libc++abi.dylib: terminating with uncaught exception of type NSException

KbNavigationController

class KabNavigationController: SlideNavigationController {

var menuItems: [(id: String, image: String, text: String)] = []

override func viewDidLoad() {
    self.leftMenu = self.storyboard?.instantiateViewController(withIdentifier: "MenuViewController")

    navigationBar.barTintColor = Theme.DarkGray
    navigationBar.tintColor = Theme.White
    navigationBar.barStyle = UIBarStyle.black

    // Popup Navigation Bar
    STPopupNavigationBar.appearance().isHidden = true

}

}

Solution

  • I have searched and debug my code alot keep in mind always enable exception break points to trigger exactly which line causing the crash. You can learn it from this Exception Breakpoint in Xcode . I found my solution here https://github.com/aryaxt/iOS-Slide-Menu/issues/250.

    move these two lines from setup function to viewWillLayoutSubviews of Slide Menu.

    //moved this from the `setup` function: 
    self.enableShadow = YES;
    self.enableSwipeGesture = YES;