Search code examples
macosswift3macos-sierra

macOS - I denied location services when prompted, and now the pop up won't show again


I'm developing a macOS application on XCode using Swift 3, and I'm getting the user's location. When the application loads for the first time, it shows a prompt asking the user for permission to access their location. It's been working since I made the app, but I then changed the name of the project, and when the popup showed again when I re-ran the app, I clicked "Cancel" for testing purposes, and now when I try to get the user's location again, the pop up doesn't show asking for permission.

I checked System Preferences -> Security & Privacy -> Privacy, and my application isn't there to re-enable location services.

Any ideas?

The code below is how I'm getting the user's location, and I'm calling this in viewDidLoad():

locationManager.delegate = self
locationManager.desiredAccuracy = kCLLocationAccuracyBest
locationManager.startUpdatingLocation()

Solution

  • If the application isn't able to find your location, that means you didn't give the app permission to use your location (obviously). Follow the directions below to reset it to ask you for permission again.

    1. Open a terminal and sudo to a root shell $ sudo -s

    2. Go to locationd/ $ cd /var/db/locationd

    3. Make a backup of clients.plist just in case $ cp -p clients.plist clients.plist.save

    4. Convert clients.plist to XML $ plutil -convert xml1 clients.plist

    5. Open the clients.plist and remove the entire that contains the Map My Route application, then save it.

    6. Convert the clients.plist back to binary $ plutil -convert binary1 clients.plist

    7. Restart locationd $ killall locationd