Swift Firebase Error: Thread 1: "Failed to get FirebaseDatabase instance: Specify DatabaseURL within FIRApp or from your databaseForApp:URL: call."

Hey guys, I want to connect my Xcode Project with Firebase to load my Userdata into the database. Although I already used the same code in another project, it doesn't work and throws me the following offer: Thread 1: "Failed to get FirebaseDatabase instance: Specify DatabaseURL within FIRApp or from your databaseForApp:URL: call."

Here is my Code:

Code Block
@objc func registerButtonTapped() {
        if acceptTermsOfUseSwitch.isOn == true && emailTextField.text?.isEmpty == false && passwordTextField.text?.isEmpty == false {
            print("Register...")
            //Authentification
        Auth.auth().createUser(withEmail: emailTextField.text!, password: passwordTextField.text!) { (data, error) in
            if let err = error {
                print(err.localizedDescription)
                return
            }
            guard let newUser = data?.user else { return }
            let uid = newUser.uid
            print("User: \(String(describing: newUser.email)) wurde erstellt, ID: \(String(describing: newUser.uid))")
            //Database
            self.uploadUserData(uid: uid, email: self.emailTextField.text!)
            }
        } else {
            print("No valid data")
        }
    }
func uploadUserData(uid: String, email: String) {
        var ref = DatabaseReference()
        ref = Database.database().reference().child("users").child(uid)
                print("Datenbank ID: \(ref)")
                ref.setValue(["email" : email, "userID" : uid])
                print("User data uploaded")
                //Change VC:
            let vc = TabBarController()
                self.dismiss(animated: true, completion: {
             UIApplication.shared.windows.first?.rootViewController = vc
            })
            }


I hope someone can help me, thanks in advance!


Firebase is not a framework of Apple's. You should better find an appropriate place to ask about it to get better responses sooner.


But generally, it is not considered to be a good habit to instantiate a class which will immediately disposed.
Code Block
var ref = DatabaseReference()
ref = Database.database().reference().child("users").child(uid)

Why don't you write it simply?
Code Block
var ref = Database.database().reference().child("users").child(uid)


At the beginning I had it like this but then I tried to change some things.

The point that makes me so angry is that I already had this error but I don't know how I solved it in the past
Swift Firebase Error: Thread 1: "Failed to get FirebaseDatabase instance: Specify DatabaseURL within FIRApp or from your databaseForApp:URL: call."
 
 
Q