swiftcrashxcode11.3

Getting crash in xcode 11.3 viewcontroller getting nill


Getting error :: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: ' returned nil from -traitCollection, which is not allowed.

It is crashing in this method func carbonTabSwipeNavigation(_ carbonTabSwipeNavigation: CarbonTabSwipeNavigation, viewControllerAt index: UInt) -> UIViewController { let sb = UIStoryboard.init(name: storybordname, bundle: nil) var viewcontroller:UIViewController! viewcontroller = sb.instantiateViewController(withIdentifier: controllername) return viewcontroller } When i Checked after putting breakpoint its crashing on the first line super.viewDidLoad()


Solution

  • Put your viewdidload code in disptachQueue

    DispatchQueue.main.asyncAfter(deadline: .now() + 0.3, execute: {
                   // Your Code
      })
    

    Like this...