Henrik
Henrik

Reputation: 4034

Reset location permission for app in development

I am building an app in Xcode that uses Core Location. On first run the app asks the user for permission. I want to revoke this permission to trigger the flow anew.

I cannot find my app in the list of apps under Settings / Location Services.

Upvotes: 2

Views: 1817

Answers (2)

BrandonS
BrandonS

Reputation: 1

Remove Application from Location Services in Security & Privacy by right clicking on the app entry and go to the app folder. Move the app to trash bin. Close Security & Privacy.

Terminal command:

  1. sudo chown -R [your Mac id] /var/db/locationd (change directory ownership temporarily to you so that you have permission to access what's in locationd folder)
  2. plutil -convert xml1 /var/db/locationd/clients.plist (convert the binary plist to text-based plist in XML format)
  3. vi /var/db/locationd/clients.plist (Edit clients.plist) arrow key to move to the starting line and use "dd" command to erase one line. Move down the lines until the key-dict pair of your app entry is removed. Use :wq command to save and quit.

Restart Mac. (Important as to make sure Location Services is not using what's in the memory. Force OS to read from clients.plist again)

P.S.: There is no need to change the ownership back to you or convert the plist file back to binary format. It will be reset to default ownership or format very soon by the OS.

Upvotes: 0

Hal Mueller
Hal Mueller

Reputation: 7646

It's odd that your app isn't in Security & Privacy->Location Services. I don't have an answer to that.

If you do uncheck the permission in that pane, though, you won't start the flow anew. Instead you'll be simulating a rejection of permission (user denied the permission request).

The tccutil command line program ought to be able to manipulate those settings. But I tried tccutil reset All on my machine and it didn't affect Location privacy.

It looks like the property list at /var/db/locationd/clients.plist has the authorized applications. So you might be able to edit that file with the plutil command line tool to remove your application. Or just make a copy, edit with Xcode to remove your application, and swap in that copy for testing.

sudo bash
plutil -p /var/db/locationd/clients.plist

Upvotes: 0

Related Questions