No such module ‘FirebaseFirestoreSwift’

Hi Chris and all. I am trying to learn how to use Firebase (and Firestore) and am taking your older Database course as it’s the only one I can see in here that teaches Firebase. There is a lot that is out of date so I’m not sure I can even use this one? Is there a better course for me to learn Firebase??

The cocoa pods did not work at all, so I used the SwiftPackage Manager to install Firebase. All seems to be ok now, but as I’m trying to start your course I cannot use FireSTORE.

I tried importing FirebaseFireStoreSwift as I found that info in an online search, but it’s not working. As you can see in the screenshot the let db = Firestore.firestore() is all in black lettering as it’s not registering the Firestore. And the build fails and then tells me "no such module ‘FirebaseFirestoreSwift’

Can anyone help? Thanks
Nadine

@nadinesaleh

Hi Nadine,

Welcome to the community.

I extracted your post from the thread you posted in and created a separate post.

There is no need to use the import statement FirebaseFirestoreSwift since in the Module there is nothing that you are doing that requires any functionality offered by that framework. Also during the Swift Package Manager setup for Firebase you would need to add that the package named FirebaseFirestoreSwift to take advantage of any capability in that framework offered. What the error message is saying is that the framework does not exist.

In order to make the function makeReservation() work, you need to call it in the init() closure after the instruction FirebaseApp.configure(). ie:

@main
struct FireStoreDemoApp: App {

    init() {
        FirebaseApp.configure()
        makeReservation()
    }

    func makeReservation() {
        let db = Firestore.firestore()
        // Add the necessary Firebase instructions to create the reservation record.
    }

    var body: some Scene {
        WindowGroup {
              ContentView()
        }
    }
}

Cheers
Chris P

Hi Chris. Thanks for your response!

I’m not quite up to that point in the coding yet. I’m just at time stamp 1:17 in the screenshot below. So before even trying to use and call on the makeReservation function I am simply trying to have my project link properly to FireStore. See second screenshot below…

(I only added the import FirebaseFirestoreSwift as an attempt to make it work but it still didn’t work)

I would really like this to work as once my project can link properly to Firebase and Firestore I think the rest of this course will still be pretty relevant and helpful - I really want to be able to continue it!

Thanks
Nadine

second screenshot

@nadinesaleh

Hi Nadine,

When you added Firebase to your project using Swift Package Manager, what frameworks did you select from those listed apart from FirebaseFirestoreSwift? In your case the only one you needed for the exercises in this Module is FirebaseFirestore

Just to be sure you have the right link to the Firebase frameworks, this is the url:

Also did you manage to successfully download your GoogleService-Info.plist file and add that to your project? Make sure that the file is named correctly and that when you dragged it into your project, you checked the Add to targets option.

Hi Chris

Thank you. Yes I followed all those instructions and actually did it a bunch of times with several new projects! I’ve been going crazy doing this haha. But the good news on that is I am now an expert add adding Firebase to projects lol I’ll never need the instructions again I’ve got it memorized!

And I’ve finally got it to work (I think!) using this:

Screenshot 2024-01-03 at 12.24.31 PM

It also seems to need a few hours or even a day to work itself out, as I tried these exact imports yesterday too and they didn’t work then!

I’ve managed to save some collections from my project into the Firestore so it’s definitely connected on some level at least now.

Thanks!
Nadine

1 Like