iosswiftxcodeappdelegaterootviewcontroller

skipping login screen in appdelegate not working in swift


I am trying to skip the login screen in appdelegate and i am using world known method of assigning the next view controller to rootviewcontroller but somehow it's not working for testing purposes I have not set any condition and this code is directly executed but doesn't reflect in the app.

my loginViewController is embedded in navigationController

let storyboard = UIStoryboard(name: "Main", bundle: nil)
let homepage = storyboard.instantiateViewController(withIdentifier: "mainTabBarController") as! mainTabBarController
self.window?.rootViewController = homepage
self.window?.makeKeyAndVisible()

I have gone through a lot so answers for this but they are suggesting the same method.

"comment for extra info on the question".


Solution

  • If you are using Xcode 11 and above

    1. Delete SceneDelegate.swift
    2. Delete UISceneSession Lifecycle methods from AppDelegate
    3. Add var window: UIWindow? in AppDelegate class
    4. Open Info.plist and delete Application Scene Manifest
    5. Add the below line in didFinishLaunchingWithOptions method
    self.window = UIWindow(frame: UIScreen.main.bounds)     
    self.window?.rootViewController = //...
    self.window?.makeKeyAndVisible()