Why is FirebaseFirestoreSwift not loading into my editor?

Viewed 25

I am able to successfully import the package FirebaseFirestoreSwift, however, any code I write using said package throws errors. The editor is acting as if the package is not imported.

import SwiftUI
import Firebase
import CryptoKit
import FirebaseFirestore
import FirebaseFirestoreSwift -- NO error on import
import AuthenticationServices

class SignInViewModel: ObservableObject {
    @Published var showSignInView: Bool = false
    @Published var nonce: String = ""
    
    @Published var currentUserData: UserModel? = nil
    
    private lazy var authRef = Auth.auth()
    private lazy var usersCollection = Firestore.firestore().collection("users")
    
    public func getCurrentUserData(_ user: User) {
        guard let currentUID = authRef.currentUser?.uid else {
            showSignInView = true
            return
        }
        usersCollection.document(currentUID).getDocument { (snapshot, error) in
            guard let document = snapshot, document.exists else {
                self.createNewUserDocument(currentUID, user)
                return
            }
            guard let userData = try? document.data(as: UserModel.self) else { return } -- ERROR #1
            self.currentUserData = userData
            showSignInView = false
        }
    }
    
    private func createNewUserDocument(_ currentUID: String, _ user: User) {
        do {
            let userData = UserModel(id: UUID().uuidString, name: user.displayName ?? "") -- ERROR #2
            try usersCollection.document(currentUID).setData(from: userData)
        } catch {
            print("Error creating new user document: \(error)")
        }
    }
}

Error #1: "Argument passed to call that takes no arguments"

Error #2: "No exact matches in call to instance method 'setData'"

From my understanding, these errors are throwing due to the fact that the package is not correctly loading. I have restarted, reimported the packages/frameworks to no success. Running Xcode 14 Firebase 9.6.0

0 Answers
Related