Passing my CloudKit query using the
let location = locationManager.location
let predicate = NSPredicate(value: true)
let query = CKQuery(recordType: "Establishment", predicate: predicate)
let sort = CKLocationSortDescriptor(key: "Location", relativeLocation: location!)
query.sortDescriptors = [CKLocationSortDescriptor(key: "Location", relativeLocation: location!)]
I used a TSI and contacted Apple. As it turns out CKLocationSortDescriptor is only accurate to 10kms, this is not a bug apparently it is actually something that they forgot to add to the documentation. The Cloudkit team are working on improving this but cannot give a time line. If you want to order anything closer than 10km you can't at this time.