Skip to content

fix(devicelab_ios): skip launch permissions and clearKeychain on stopApp: false - #261

Merged
omnarayan merged 1 commit into
devicelab-dev:mainfrom
benalbrecht:fix_stop_app_false
Nov 9, 2026
Merged

omnarayan merged 1 commit into
devicelab-dev:mainfrom
benalbrecht:fix_stop_app_false

Conversation

@benalbrecht

Copy link
Copy Markdown
Contributor

Summary

Fixes an issue in the DeviceLab iOS driver where launchApp with stopApp: false terminated running applications instead of bringing them to the foreground.

applyLaunchPermissions (which runs simctl privacy grant all) and clearKeychain were being executed unconditionally before checking keepsRunningApp(s).
On iOS, mutating privacy permissions via simctl privacy prompts the TCC daemon (tccd) to immediately kill the process with OS_REASON_TCC | Access to service kTCCServiceAll changed. As a result, the subsequent simctl launch command spawned a fresh process from scratch instead of foregrounding the existing one, discarding any in-memory app state.

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)

Changes Made

  • pkg/driver/devicelab_ios/lifecycle.go: Wrapped applyLaunchPermissions and ClearKeychain in if !keepsRunningApp(s) so that bringing an app to the front does not reset/grant permissions or reset the keychain.
  • pkg/driver/devicelab_ios/lifecycle_test.go: Updated TestLaunchAppDefaultsAndErrors to assert all: allow default permissions on a standard launch (StopApp: nil) rather than StopApp: boolp(false). TestLaunchAppStopAppFalseKeepsRunningApp continues to verify that stopApp: false brings the app forward without termination.

Related Issues

Aligns implementation with documented behavior in CHANGELOG.md ("DeviceLab iOS: launchApp with stopApp: false brings a running app to the front instead of restarting it, as Maestro does").

Testing

  • Tests pass locally (make test / go test ./pkg/driver/devicelab_ios/...)
  • Linting passes (gofmt, go vet ./pkg/driver/devicelab_ios/...)
  • Added tests for new functionality
  • Tested manually with sample flows (verified on real iOS 27.2 simulator test suite across backgrounding/foregrounding flows preserving in-memory timer state)

Checklist

  • Code follows project style guidelines
  • Self-reviewed the code
  • Added/updated documentation as needed
  • No breaking changes (or documented if breaking)
  • CHANGELOG.md updated (for notable changes)

Additional Notes

Verified with simctl spawn log show --predicate 'process == "tccd" or process == "runningboardd"' that iOS no longer terminates the running bundle ID when foregrounded with stopApp: false.

…App: false

When launchApp runs with stopApp: false to foreground a running app, applying
launch permissions (simctl privacy grant all) or resetting keychain triggers
iOS TCC to terminate the running process with OS_REASON_TCC, preventing
stopApp: false from keeping the app alive. Skip permission application and
keychain reset when keepsRunningApp(s) is true.
@omnarayan
omnarayan merged commit 5cc6b1f into devicelab-dev:main Nov 9, 2026
omnarayan pushed a commit that referenced this pull request Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants