Skip to content

fix(EventMonitor): Accessibility permission not detected on TestFlight builds #98

Closed

Description

@owieth

Problem

When installed via TestFlight, AXIsProcessTrustedWithOptions returns false even though the app is enabled in System Settings > Privacy & Security > Accessibility. Toggling the permission doesn't resolve it. The app runs in a container path (Library/Containers/com.inputmetrics.InputMetrics/).

Logs on startup:

Database path: ~/Library/Containers/com.inputmetrics.InputMetrics/Data/Library/Application Support/InputMetrics/metrics.db
Database initialized successfully
InputMetrics launched successfully
⚠️ Accessibility permission not granted
📋 Please enable InputMetrics in System Settings > Privacy & Security > Accessibility

Root Cause

AXIsProcessTrustedWithOptions queries the TCC database for the exact executable path. TestFlight/App Store builds run from a different path than dev builds, and the sandbox container changes the process identity. The TCC entry may not match what the runtime resolves.

Proposed Fix

File: InputMetrics/InputMetrics/Services/EventMonitor.swift

  1. Remove the AXIsProcessTrustedWithOptions gate. Instead, attempt CGEvent.tapCreate(...) directly — if it returns nil, permission is denied. This tests the actual capability rather than querying TCC.

  2. Add polling retry. After showing the permission alert, poll every 2 seconds (up to 30 attempts) trying to create the event tap. Once it succeeds, start monitoring — no app restart needed.

  3. Keep the alert/prompt directing the user to System Settings on initial failure.

Updated start() flow:

start()
├─ try CGEvent.tapCreate(...)
├─ success → wire up run loop, done
└─ nil (denied) →
    ├─ show NSAlert with "Open System Settings" button
    └─ start polling timer (every 2s, up to 30 attempts)
         └─ each tick: try CGEvent.tapCreate(...)
              ├─ success → wire up run loop, cancel timer
              └─ nil → continue polling

Changes:

  • Remove checkAccessibilityPermission() and requestAccessibilityPermission() methods
  • Extract tap creation + run loop wiring into private func createAndStartEventTap() -> Bool
  • Add a Timer that retries every 2s, cancel on success or after 30 attempts

Verification

  1. Build and archive with Release config
  2. Install via TestFlight
  3. Grant Accessibility permission when prompted
  4. Confirm "Event monitoring started" appears without restarting the app

Activity

  1. self-assigned this
    on Mar 12, 2026
  2. added
    bug
    on Mar 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions