Combining swiftUI and Firebase

Hello,

This is my first post here.
Saw a bunch of tutorials about Swift and Firebase but none about what i want to accomplish.

I want to create an app which starts up showing the pre built firebase UI. From there the user can select a signup method and sign in to the app.

Steps i have taken sofar

Added firebase.config() to the appDelegate file
Added following to the sceneDelegate file in the

**func** scene( **_** scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {

let authUI = FUIAuth.defaultAuthUI()

    guard authUI != nil else {
        print("No authUI")
        
        return
    }
    
    authUI!.delegate = self

    // Create the SwiftUI view that provides the window contents.
    let authView = authUI!.authViewController()
    let contentView = ContentView(authView: authView)

Now i wanted to add the UINavigationController in the authView as my rootController as follows

window!.rootViewController = authView

But this gives me following error

Fatal error: Unexpectedly found nil while unwrapping an Optional value:

I can’t figure out why my authView is nill ?

Any help would be appreciated

are you sure that the authView is nil?, maybe posting a screenshot would be better

Bad case of staring at something to long.
I looked over the code and realized i forgot to initialize the window variable. (DOH!)

Got it working now :slight_smile:

2 Likes