App crashed on iOS 13, after switching rootviewcontroller

Application runs fine on iOS 12. But crashed on iOS 13.1. I think the issue is in the setting root view controller.

let storyboard = UIStoryboard(name: storyBoard, bundle: nil)
let desiredViewController = storyboard.instantiateViewController(withIdentifier: identifier);
self.window?.switchRootViewController(desiredViewController,animated: animate,options:options)


and the extension is:

extension UIWindow {
func switchRootViewController(_ viewController: UIViewController, animated: Bool = true, duration: TimeInterval = 0.3, options: UIView.AnimationOptions = .transitionFlipFromRight, completion: (() -> Void)? = nil) {
guard animated else {
rootViewController = viewController
return
}
UIView.transition(with: self, duration: duration, options: options, animations: {
let oldState = UIView.areAnimationsEnabled
UIView.setAnimationsEnabled(false)
self.rootViewController = viewController
UIView.setAnimationsEnabled(oldState)
}) { _ in
completion?()
}
}
}

Replies

Where exactly does it crash ? Crash log ?


let storyboard = UIStoryboard(name: storyBoard, bundle: nil)
let desiredViewController = storyboard.instantiateViewController(withIdentifier: identifier);
self.window?.switchRootViewController(desiredViewController,animated: animate,options:options)


extension UIWindow {
   
    func switchRootViewController(_ viewController: UIViewController, animated: Bool = true, duration: TimeInterval = 0.3, options: UIView.AnimationOptions = .transitionFlipFromRight, completion: (() -> Void)? = nil) {
        guard animated else {
            rootViewController = viewController
            return
        }
       
        UIView.transition(with: self, duration: duration, options: options, animations: {
            let oldState = UIView.areAnimationsEnabled
            UIView.setAnimationsEnabled(false)
            self.rootViewController = viewController
            UIView.setAnimationsEnabled(oldState)
        }) { _ in
            completion?()
        }
    }
}

objc[6701]: Class CLSUserDefaults is implemented in both /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/System/Library/Frameworks/ClassKit.framework/ClassKit (0x11ae05280) and /Users/surya/Library/Developer/CoreSimulator/Devices/1F9A9911-F2A9-4704-89E4-75087093B028/data/Containers/Bundle/Application/2C2A2C61-9D23-4C00-B602-53BB6880DD9F/VisibleClassroom.app/VisibleClassroom (0x1043c7800). One of the two will be used. Which one is undefined.

2019-11-01 11:58:40.146525+0530 VisibleClassroom[6701:194980] - <AppMeasurement>[I-ACS036002] Analytics screen reporting is enabled. Call +[FIRAnalytics setScreenName:setScreenClass:] to set the screen name or override the default screen class name. To disable screen reporting, set the flag FirebaseScreenReportingEnabled to NO (boolean) in the Info.plist

2019-11-01 11:58:40.375847+0530 VisibleClassroom[6701:194426] [Crashlytics] Version 3.12.0 (136)

2019-11-01 11:58:40.403410+0530 VisibleClassroom[6701:194426] [Fabric] [Fabric +with] called multiple times. Only the first call is honored, please pass all kits you wish to initialize

2019-11-01 11:58:40.418663+0530 VisibleClassroom[6701:194426] [framework] CoreUI: RunTimeThemeRefForBundleIdentifierAndName() couldn't find Assets.car in bundle with identifier: '(null)'

2019-11-01 11:58:40.418842+0530 VisibleClassroom[6701:194426] [framework] CoreUI: RunTimeThemeRefForBundleIdentifierAndName() couldn't find Assets.car in bundle with identifier: '(null)'

2019-11-01 11:58:40.447016+0530 VisibleClassroom[6701:195012] 5.13.0 - [Firebase/Analytics][I-ACS023007] Analytics v.50300000 started

2019-11-01 11:58:40.448010+0530 VisibleClassroom[6701:195012] 5.13.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r)

Permission granted: true

Notification settings: <UNNotificationSettings: 0x600002fcf2c0; authorizationStatus: Authorized, notificationCenterSetting: Enabled, soundSetting: Enabled, badgeSetting: NotSupported, lockScreenSetting: Enabled, carPlaySetting: NotSupported, announcementSetting: NotSupported, criticalAlertSetting: NotSupported, alertSetting: Enabled, alertStyle: Banner, groupingSetting: Default providesAppNotificationSettings: No>

Network Status Changed: reachable(Alamofire.NetworkReachabilityManager.ConnectionType.ethernetOrWiFi)