How to show permissions for Location Services at Privacy & Security menu?

My MacOS software uses the Location Services, previously to Ventura the user could allow the app to use or deny the use of location. Now Ventura won't show up my software name there, so the user can't enable/disable it.

My software is a kind of service (main code is terminal) and I have a GUI to setup the parameters.

I can't find any topic related to changes with Ventura. Anyone could help me on this?

Replies

Adding something else to this thread. Here a sample code that I use in my original code (not exactly this way, but the main part is quite close)

I started a new Command Line Tool with Xcode 14.2, i notice that there's no more config.plist so I take from my app to ensure that NSLocationAlwaysUsageDescription, NSLocationUsageDescription and NSLocationWhenInUseUsageDescription are there - config.plist attached here too. No luck with Ventura so far.

import Foundation
import CoreLocation

struct TCoordinates {
  var latitude: Double = 0
  var longitude: Double = 0
  var altitude: Double = 0
  var course: Double = 0
  var precision: Double = 0
}

let locationManager = CLLocationManager()
var coordinates: TCoordinates

coordinates = TCoordinates.init()

func getCoordinates(locationManager: CLLocationManager) -> TCoordinates {
  var ret = TCoordinates.init()
  ret.latitude = locationManager.location?.coordinate.latitude ?? 0
  ret.longitude = locationManager.location?.coordinate.longitude ?? 0
  ret.altitude = locationManager.location?.altitude ?? 0
  ret.course = locationManager.location?.course ?? 0
  ret.precision = locationManager.location?.horizontalAccuracy ?? 0
  return ret
}

private func locationManager(manager: CLLocationManager!, didChangeAuthorizationStatus status: CLAuthorizationStatus) {
  switch status {
  case .notDetermined:
    // If status has not yet been determied, ask for authorization
    manager.requestWhenInUseAuthorization()
    break
  case .authorizedWhenInUse:
    // If authorized when in use
    manager.startUpdatingLocation()
    break
  case .authorizedAlways:
    // If always authorized
    manager.startUpdatingLocation()
    break
  case .restricted:
    // If restricted by e.g. parental controls. User can't enable Location Services
    break
  case .denied:
    // If user denied your app access to Location Services, but can grant access from Settings.app
    break
  default:
    break
  }
}

func getGeoLocation() {
  coordinates = getCoordinates(locationManager: locationManager)
   
  if CLLocationManager.locationServicesEnabled() {
     
    let authorizationStatus: CLAuthorizationStatus
     
    if #available(iOS 14, *) {
      authorizationStatus = locationManager.authorizationStatus
    } else {
      authorizationStatus = CLLocationManager.authorizationStatus()
    }
     
    switch authorizationStatus {
    case .restricted, .notDetermined:
      locationManager.requestAlwaysAuthorization()
      print("Restricted")
      exit(0)
    case .denied:
      print("Denied")
    case .authorizedAlways, .authorizedWhenInUse:
      print("Authorized")
    case .authorized:
      print("Authorized")
    @unknown default:
      print("Unavailable")
    }
  }

}

/* -------- */

locationManager.startUpdatingLocation()
   
getGeoLocation()

autoreleasepool {
  RunLoop.main.run()
}
  • That sample is a bit messed, after post I was unable to edit and that getGeoLocation() function should/could be ignored.

Add a Comment