I can't seem to connect to my Firestore database. The specific error I am getting is "Failed to get FirebaseApp instance. Please call FirebaseApp.configure() before using Firestore". However, I've already called the configure function. Here is my code for the section I am writing:
let db = Firestore.firestore()
I have also properly configured Firebase in AppDelegate like so
FirebaseApp.configure()
Any help on this at all would be really appreciated, I cant seem to figure out what's going on.
This is the section in reference for context:
import SwiftUI
import Firebase
import FirebaseDatabase
import Foundation
struct Practioner: Identifiable {
var id: ObjectIdentifier
var name: String
var email: String
var gender: String
var provider: String
var education: String
var subspeciality: String
var languages: String //fix this to array
var indigenous: Bool
var lgbtq: Bool
var rural: Bool
}
public struct DemographicsView: View {
@State var genderSel = ""
@State var providerSel = ""
@State var educationSel = ""
@State var subspecialtySel = ""
@State var languageSel = ""
@State var indigenousSel = false
@State var lgbtqSel = false
@State var ruralSel = false
@EnvironmentObject var settings: UserSettings
@EnvironmentObject var session: sessionStore
var genders = ["Male", "Female", "Other"]
init(){
UITableView.appearance().backgroundColor = .clear
}
public var body: some View {
VStack {
NavigationView {
Form {
Text("Demographics")
.font(.largeTitle)
.fontWeight(.semibold)
.padding(.bottom, 20)
Text("Please specify the following details about
yourself")
.font(.title)
.fontWeight(.semibold)
.padding(.bottom, 20)
Section(){
Picker(selection: $genderSel, label:
Text("Gender")) {
ForEach(0 ..< genders.count){
Text(self.genders[$0]).tag($0)
}
}
Picker(selection: $providerSel, label:
Text("Provider Type")) {
Text("Doctor").tag(1)
Text("Nurse").tag(2)
Text("Other").tag(3)
}
Picker(selection: $educationSel, label:
Text("Country of education")) {
Text("Canada").tag(1)
Text("USA").tag(2)
Text("Other").tag(3)
}
Picker(selection: $subspecialtySel, label:
Text("Subspecialty")) {
Text("OGBYN").tag(1)
Text("Family doctor").tag(2)
Text("Other").tag(3)
}
Picker(selection: $languageSel, label:
Text("Language(s)")) {
Text("English").tag(1)
Text("French").tag(2)
Text("Malayalam").tag(3)
}
}
Toggle(isOn: $indigenousSel) {
Text("Indigenous")
}
Toggle(isOn: $lgbtqSel) {
Text("LGBTQ+ (optional)")
}
Toggle(isOn: $ruralSel) {
Text("Rural")
}
Section(){
Button(action: {
let db = Firestore.firestore()
}) {
LoginButtonView(textField: "Sign up")
}.frame(minWidth: 0, maxWidth: .infinity,
minHeight: 0,maxHeight: .infinity, alignment: .center)
}
}
}.navigationBarHidden(true)
.navigationBarTitle(Text("Home"))
.edgesIgnoringSafeArea([.top, .bottom])
}
}
}