I have tried to install GeoFire in Xcode/Swift.
According to the documentation (https://firebase.google.com/docs/firestore/solutions/geoqueries), this is done by adding "GeoFire/Utils" to Podfile. However, once installed I see errors. I’m suspecting this is caused from incompatibility with Firebase 10.23.1?
Why is this not available from Swift Package Manager?
Is "GeoFire/Utils" not maintained any more?
Are there any alternatives?
2
Answers
In recent releases it is no longer necessary to use geohashes and geofire to perform geoqueries on Firestore. Instead you can perform range conditions on the latitude and longitude values in your documents.
I just created an example this over the weekend in JavaScript that you can find here: https://stackblitz.com/edit/geofire-geoquery-2024. The important code from there:
So this is a query on the
longitude
andlatitude
fields in my documents, which describe the location of the document. This type of query only recently became possible on Firestore, and is documented in query with range and inequality filters on multiple fields and optimize these queries.The variables use in the code are:
You’ll have to translate this code to Swift for your use-case, but after that you’ll no longer need the geofire library.
Here is Frank’s code in Swift