Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot find publish() function #21

Open
kencoken opened this issue Oct 24, 2021 · 2 comments
Open

Cannot find publish() function #21

kencoken opened this issue Oct 24, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@kencoken
Copy link

kencoken commented Oct 24, 2021

Apologies if am missing something as a bit of a Combine novice. I have installed CombineFirebase 0.3.0 and Firebase 7.11.1 and am trying to follow the example from the readme file for listening to a collection in Firestore:

import CombineFirebase
import Firebase
import Combine

let db = Firestore.firestore()
var cancelBag = Set<Cancellable>()

func listenCollection() {
    db.collection("cities")
        .publisher()
        .sink(receiveCompletion: { completion in
            switch completion {
            case .finished: print("🏁 finished")
            case .failure(let error): print("❗️ failure: \(error)")
            }
        }) { snapshot in
            print("collection data: \(snapshot.documents)")
        }.store(in: &cancelBag)
}

However, Swift is unable to find the publisher() method on db.collection("cities") with only a:

publisher(for keyPath: KeyPath<CollectionReference, Value>)

I can see this exists on the Query object on the source code here so am unsure why db.collection("cities") which returns a CollectionReference (which derives from Query) can not find this definition.

@kencoken
Copy link
Author

kencoken commented Nov 2, 2021

I can further confirm that this only happens when I install the package using the Swift Package Manager and not CocoaPods.

If importing the relevant sub-package directly then the compilation works:

import CombineFirebaseFirestore

So it seems that something is going wrong with the global import.

@kshivang
Copy link
Collaborator

Yes you are right, import issue is there with SPM version, you have to use respective module import as of now, new PR is welcomed on this.

@kshivang kshivang added the enhancement New feature or request label Jan 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants