Set root view controller in swift

var navigationController:UINavigationController?
let storyBoard = UIStoryboard(name: "Main", bundle: nil)
let homeVC = HomeViewController(nibName: "HomeViewController", bundle: nil)
self.navigationController = UINavigationController(rootViewController: homeVC)
self.window?.rootViewController = self.navigationController
self.window?.makeKeyAndVisible()
let VCLogin = storyBoard.instantiateViewController(withIdentifier: "LoginViewController") as! LoginViewController
self.navigationController = UINavigationController(rootViewController: VCLogin)
self.window?.rootViewController = self.navigationController
self.window?.makeKeyAndVisible()