Reputation: 77
I was working on a project on xcode in swift and everything was okay with firebase, until I got this error: (FirebaseApp.configure()
in Swift) before using Firebase Database.' I'm guessing it happened after I added Auth.auth.currentuser. But the problem is not solved even after I removed the code Auth.auth().cutrent user. I tried replacing the GoogleServices.plist with a new one. But still no luck.
Upvotes: 1
Views: 1457
Reputation: 7546
Check to ensure that your database isn't being initialized before using it. If you have the following in your initial view controller:
var ref = Database.database().reference()
That can cause the error you're describing. Instead, you can use
var ref: DatabaseReference!
and then assign a value when you actually use the reference, or use lazy
so the variable isn't instantiated until the first time it's actually used.
lazy var ref = Database.database().ref()
If you're still experiencing the issue, I suggest you create a minimum reproducible code example and then update your question. Without showing any code, this is my best theory.
Upvotes: 2
Reputation: 1598
You need to import Firebase
into your AppDelegate.swift
file, as well as add FirebaseApp.configure()
in the didFinishLaunchingWithOptions
method; which is also inside your AppDelegate.swift
.
Also, have you made sure that you're opening your .xcworkspace
file instead of the .xcodeproj
Upvotes: 0