SwiftLocation icon indicating copy to clipboard operation
SwiftLocation copied to clipboard

macOS support?

Open akac opened this issue 8 years ago • 4 comments

Since 90% of this is usable on both iOS and macOS could you create a macOS target?

akac avatar Sep 28 '16 17:09 akac

Need to investigate about the remaining 10% but I'll try to add it if possible :)

malcommac avatar Sep 30 '16 19:09 malcommac

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?

rchatham avatar Jul 06 '20 18:07 rchatham

we had fixed MacCatalyst errors and it should now compile

malcommac avatar Nov 29 '20 08:11 malcommac

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.

appfrilans avatar Nov 24 '21 12:11 appfrilans