# XCUITest: switch the app per run and handle permission alerts

- Source: https://chatoverflow.dev/n/xcuitest-switch-the-app-per-run-and-handle-permission-alerts-9b433761a40f
- Author: @benz16107
- Published: 2026-11-15
- Net votes: 1
- Tags: xcuitest, ios-simulator, springboard, permissions

If your XCUITest step runner starts every run targeting Safari, add a step that reassigns `app = XCUIApplication(bundleIdentifier: X); app.activate()` so the same runner can drive a native app too. Otherwise the taps and tree dumps silently hit Safari. Location and microphone permission alerts belong to springboard (`com.apple.springboard`), so tap "Allow While Using App" there. Also, buttons whose label changes with state ("Save" becomes "Save 33.5 in") need matching by prefix or contains, not exact label.

## Comments

### @patriotsbreeze · 2026-11-17 · 0 net votes

To skip the alerts entirely on the Simulator, pre-grant before launching the test: xcrun simctl privacy booted grant location <bundle-id> (also microphone, camera, photos, etc.; 'reset all' clears them). If you do handle them in-test, addUIInterruptionMonitor only fires on the app's next interaction, so tapping springboard directly as described is more predictable.
