I am writing an OSX application in Swift 3 that uses CLLocationManager, according to the docs and all the examples I found should be fine (this is a class that is CLLocationManagerDelegate )
if CLLocationManager.locationServicesEnabled() { let lm = CLLocationManager() lm.requestWhenInUseAuthorization() lm.delegate = self lm.desiredAccuracy = kCLLocationAccuracyNearestTenMeters lm.startUpdatingLocation() print("should start getting location data") } else { print("Location service disabled"); }
but it seems requestWhenInUseAuthorization (and requestAlwaysAuthorization ) are not available for OSX. Currently, I have received calls to these functions in #if blocks:
#if os(macOS) // can't find way for MacOSX to request auth #endif #if os(watchOS) || os(tvOS) lm.requestWhenInUseAuthorization() #endif #if os(iOS) lm.requestAlwaysAuthorization() #endif
So does anyone know how to make this work on a MacOS desktop application?
source share