在Storyboard.instantiate时发现nil

我正在使用Firebase构建一个出租应用程序。我有一个屏幕``WelcomeViewController'',现在该屏幕的功能是当应用启动时,它会检查用户是否登录。如果是,那么它将执行Storyboard实例化到HomeScreenViewController,并且如果用户已注销,则应该将Storyboard实例化到LoginViewController。现在,第一部分运行良好,并且Storyboard确实实例化到HomeScreenViewController,但是在第二部分中,运行Storyboard.instantiate时,它崩溃并显示错误“发现nil,而强制展开可选内容”。我已经交叉检查了所有情节提要ID和所有内容。我似乎不知道。

导入UIKit 导入Firebase

类WelcomeViewController:UIViewController {

var docRef:DocumentReference!
var Uid:String?
var homeVC:UITabBarController? = nil



override func viewDidLoad() {
    super.viewDidLoad()
    if Auth.auth().currentUser != nil {
        //User is signed in
        print("User is logged in")
        docRef = Firestore.firestore().document("Users/\(Auth.auth().currentUser!.uid)")
        docRef.getDocument { (docSnapshot, error) in
            guard let docSnapshot = docSnapshot, docSnapshot.exists else { print("Error Founddddd");return}
            let myData = docSnapshot.data()
            let type = myData?["Role"] as? String ?? ""
            print(type)

            if type == "Owner" {
                self.homeVC = self.storyboard?.instantiateViewController(identifier: "OwnerHome") as? OwnerHomeTabBarViewController
                self.view.window?.rootViewController = self.homeVC
                self.view.window?.makeKeyAndVisible()

            }
            else {
                self.homeVC = self.storyboard?.instantiateViewController(identifier: "TouristHome") as? TouristHomeTabBarViewController
                self.view.window?.rootViewController = self.homeVC
                self.view.window?.makeKeyAndVisible()
            }
        }

    }

      else {
             print("User is loggedout")
            //Send User to Login/Signup Screen
        let Storyboard = UIStoryboard(name: "Main", bundle: Bundle.main)
        let LoginVC = Storyboard.instantiateViewController(identifier: "loginScreen") as! SignInViewController
        self.view.window!.rootViewController = LoginVC  //Error is coming here
        self.view.window?.makeKeyAndVisible()



        }

    }

}