Skip to content

setting userTracking permission on iOS 18 & Xcode 16 (beta) #4524

Open
@asafkorem

Description

@asafkorem
Contributor

What happened?

The userTracking privacy permission cannot be set on iOS 18 using Xcode 16 (beta).
The current method in AppleSimUtils is no longer functional, and simctl does not support this permission type.

What was the expected behaviour?

The expectation was to set the userTracking privacy permission successfully using launch-args (on iOS 18 with Xcode 16).

Was it tested on latest Detox?

  • I have tested this issue on the latest Detox release and it still reproduces.

Help us reproduce this issue!

  1. Install iOS 18 (beta) and Xcode 16 (beta).
  2. Pass userTracking permission with the respective value on launchArgs to attempt setting the user-tracking privacy permission (see API).

Activity

PedroRobalo1994

PedroRobalo1994 commented on Dec 9, 2024

@PedroRobalo1994

Was able to reproduce this issue with the launch-args detoxDisableWebKitSecurity on iOS 18.0 and iOS 18.1. It works as expected on iOS 17.5,
This issue causes some of our Web Views tests to fail on iOS 18 and above with XCode 16.

Faliszek

Faliszek commented on Mar 3, 2025

@Faliszek

I also hit this issue. In my case I want to prevent modal from being shown in certain test case. As workaround I call bash script inside of the test that updates TCC database where value of kTCCServiceUserTracking permission is, inside of access table.

In test:

import { device } from 'detox';

const BUNDLE = `your.app.bundle`;

export const enableUserTrackingViaBashScript = (value: 'YES' | 'NO') => {
    exec(`./set_att_permission.sh ${device.id} ${BUNDLE} ${value}`, (err, _stdout, stderr) => {
        if (err) {
            console.error('Error:', err);
            return;
        }
        if (stderr) {
            console.error('STDERR:', stderr);
        }
        console.log(`App Tracking permission set to ${value} for device ${device.id}`);
    });
};


describe('Log in flow', () => {
    beforeEach(async () => {
        await device.launchApp({
            delete: true,
        });
        enableUserTrackingViaBashScript('YES');
    });
   // ... my tests
});

Here is the script set_att_permission.sh.
(Remember about chmod u+x ./set_att_permission.sh !)

#!/bin/bash

# Script for setting App Tracking Transparency permissions
# Usage: ./set_att_permission.sh <simulator_id> <bundle_id> <YES|NO>

# Check arguments
if [ "$#" -lt 3 ]; then
    echo "Usage: $0 <simulator_id> <bundle_id> <YES|NO>"
    exit 1
fi

# Parse arguments
SIMULATOR_ID="$1"
BUNDLE_ID="$2"
PERMISSION_STATUS="$3"

# Convert permission status to value
if [ "$PERMISSION_STATUS" = "YES" ]; then
    PERMISSION_VALUE=2
elif [ "$PERMISSION_STATUS" = "NO" ]; then
    PERMISSION_VALUE=0
else
    echo "Error: Permission status must be 'YES' or 'NO'"
    exit 1
fi

echo "Simulator ID: $SIMULATOR_ID"
echo "Bundle ID: $BUNDLE_ID"
echo "Permission status: $PERMISSION_STATUS"

# Get the physical path to the TCC database on the host machine
DEVICE_DIR="$HOME/Library/Developer/CoreSimulator/Devices/$SIMULATOR_ID"
TCC_DB_PATH="$DEVICE_DIR/data/Library/TCC/TCC.db"

echo "Physical TCC database path: $TCC_DB_PATH"

# Check if the file exists
if [ ! -f "$TCC_DB_PATH" ]; then
    echo "Error: TCC database file not found at: $TCC_DB_PATH"
    exit 1
fi

# Current timestamp
TIMESTAMP=$(date +%s)

sqlite3 "$TCC_DB_PATH" "INSERT OR REPLACE INTO access (service, client, client_type, auth_value, auth_reason, auth_version, flags, last_modified) VALUES ('kTCCServiceUserTracking', '$BUNDLE_ID', 0, $PERMISSION_VALUE, 3, 1, 0, $TIMESTAMP);"

# Verify the change was made
echo "Verifying change:"
sqlite3 "$TCC_DB_PATH" "SELECT service, client, auth_value FROM access WHERE service='kTCCServiceUserTracking' AND client='$BUNDLE_ID';"

echo "App Tracking Transparency permission for $BUNDLE_ID is now set to $PERMISSION_STATUS"

Script updates sqlite table where information about iOS permission are stored for your device.id.
After that Tracking Transparency modal is no longer shown.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @Faliszek@PedroRobalo1994@asafkorem

        Issue actions

          setting `userTracking` permission on iOS 18 & Xcode 16 (beta) · Issue #4524 · wix/Detox