title: Set rootViewController iOS 13
body: <p>After upgrading Xcode a critical part of my application has stopped working. </p>
  
  <p>When my app launches I run a function to check boolean flags and set the correct rootViewController.</p>
  
  <p>But the code I have been using to set this has now stopped working</p>
  
  <pre><code>class func setLoginAsInitialViewContoller(window:UIWindow) {
      print("SET LOGIN") 
      let storyboard = UIStoryboard(name: "Login", bundle: nil)
      let controller = storyboard.instantiateViewController(withIdentifier: "LoginViewController")
      controller.modalPresentationStyle = .overFullScreen
      window.rootViewController = controller
      window.makeKeyAndVisible()
  }
  </code></pre>
  
  <p>Specifically when the app gets the the second last line <code>window.rootViewController = controller</code> it crashes with a <code>libc++abi.dylib: terminating with uncaught exception of type NSException</code> error.</p>
  
  <p>The above function is in a class called <code>Utilities.swift</code> and I am calling the function from within my <code>AppDelegate.swift</code> as shown below:</p>
  
  <pre><code>class AppDelegate: UIResponder, UIApplicationDelegate {
  
      var window: UIWindow?
      var storyboard: UIStoryboard? = nil
  
      func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -&gt; Bool {
  
          UIApplication.shared.isIdleTimerDisabled = true
          Utilities.decideInitialViewController(window: self.window!)
  
          return true
      }
  </code></pre>
  
  <p>Any solutions or fixes on how I can set the root controller is much appreciated.</p>
  
  <p>Thank!</p>