Cannot find publish() function
kencoken opened this issue ยท 2 comments
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.
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.
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.