SwiftLocation
SwiftLocation copied to clipboard
macOS support?
Since 90% of this is usable on both iOS and macOS could you create a macOS target?
Need to investigate about the remaining 10% but I'll try to add it if possible :)
Any progress on this? For MacCatalyst it looks like the only errors occur at lines 752 and 756. I'm looking into it myself but looking at how this issue has been open for 4 years, do you know of anyone using it on MacOS?
we had fixed MacCatalyst errors and it should now compile
Catalyst compile just fine for me. But experience some issues where the then() closure is not called after this kind of code:
performOnMainThread {
SwiftLocation.gpsLocationWith {
// configure everything about your request
$0.subscription = .single // continous updated until you stop it
$0.accuracy = accuracy
$0.precise = UIDevice.current.isMac ? .reducedAccuracy : nil
// $0.minDistance = 300 // updated every 300mts or more
// $0.minInterval = 30 // updated each 30 seconds or more
$0.activityType = .other
$0.timeout = .delayed(UIDevice.current.isMac ? 5 : 15) // 5 seconds of timeout after auth granted
}.then { result in // you can attach one or more subscriptions via `then`.
switch result {
/*case .failure(let .requiredLocationNotFound(errorReason)) where errorReason.last != nil:
let fetchedLocation = FetchedLocation(from: errorReason.last!)
debugPrint("requiredLocationNotFound, returning non-nil last")
onSuccess?(fetchedLocation) */
case .failure(let error):
debugPrint("Received location error: \(error)")
onFailure?(error)
case .success(let location):
self.lastSuccessfulGPSFetch = Date()
debugPrint("Location received: \(location)")
let fetchedLocation = FetchedLocation(from: location)
onSuccess?(fetchedLocation)
}
}
}
The timeout does help either. No callback what so ever.