Is there an official way to grant/examine/revoke the "user tracking" permission to/of an iOS app on the simulator during testing?
This is the permission that corresponds to the NSUserTrackingUsageDescription entry in the info.plist, and the dialog that pops up during runtime that reads:
Allow "YourApp" to track your activity across other companies' apps and websites?
Currently running on an iPhone 14 Pro simulator running iOS 16.2. Lacking an official way, what other solutions exist?
Note that granting all permissions via simctl does not appear to do the trick, e.g.:
xcrun simctl privacy $DEVICE_ID grant all $BUNDLE_ID
does not grant the tracking permission to the app: the user is still prompted for this permission even after executing that command.
Ideally, I'd like to be able to: grant the permission to the app, examine if the permission has been granted, and revoke the granted permission.
Here is one solution that involves manipulating the
TTC.dbdatabase of the simulator, as mentioned in this answer or this gist. It's not very official and I hope someone has a better solution.Given a device id[1]
DEVICE_ID, the database containing certain app permissions should be located at:Then using the sqlite3 client, we can examine the permissions for our app with
BUNDLE_IDlike so:The result looks something like:
Where the presence of the lines indicates the permission has been granted. If a line is missing, it hasn't been granted.
We can remove all permissions like so:
Finally we can grant the tracking permission like so:
[1] the
udidentry of one of the values inxcrun simctl list devices --json