Skip to content

[BUG] clearState on iOS reinstalls app, requires --app-file (Maestro CLI clears in-place) #69

@jongbelegen

Description

@jongbelegen

Description

clearState on iOS simulators requires the --app-file flag and performs a full uninstall + reinstall of the app. Maestro CLI's clearState clears app data in place without uninstalling, so flows that use clearState for fast per-test resets are not portable to maestro-runner without reconfiguration.

Beyond the configuration burden, the reinstall path is fragile: pointing --app-file at the currently-installed .app inside ~/Library/Developer/CoreSimulator/Devices/<UDID>/data/Containers/Bundle/Application/<UUID>/ fails because the simulator container is removed by the uninstall step before the reinstall step runs (lstat ... failed: No such file or directory). Users must keep a separate copy of the .app (e.g. from DerivedData) just to satisfy the reinstall.

Steps to Reproduce

  1. Run a flow containing clearState on an iOS simulator without --app-file:

    maestro-runner --platform ios --device <UDID> test flow.yaml
    appId: com.example.app
    ---
    - clearState
  2. The same flow runs cleanly under maestro CLI with no extra config.

Expected Behavior

Either:

  • clearState clears app data in place (matching Maestro CLI behavior — no --app-file required), or
  • The reinstall path is robust to the case where --app-file points at the live simulator-container path (resolve and cache the .app before uninstall).

A documented option flag (e.g. --clear-state-mode=data|reinstall) would also resolve this.

Actual Behavior

Without --app-file:

✗ clearState (1.0s)
  ╰─ clearState on iOS requires --app-file for reinstall
Usage: maestro-runner --app-file <path-to-ipa-or-app> --platform ios test <flow-files>

With --app-file pointing at the live simulator-container path:

✗ clearState (2.0s)
  ╰─ simctl install failed: exit status 2: An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Simulator device failed to install the application.
Underlying error (domain=NSPOSIXErrorDomain, code=2):
	lstat of /Users/.../CoreSimulator/Devices/<UDID>/data/Containers/Bundle/Application/<UUID>/MyApp.app failed: No such file or directory

(The path is valid before clearState runs; uninstall removes the container, then the reinstall fails.)

With --app-file pointing at a DerivedData .app: works, but adds 1.5–3s per clearState and requires the user to track a separate .app path outside the simulator.

Environment

  • OS: macOS 15.0 (Darwin 24.6.0)
  • maestro-runner version: 1.1.13 (commit 7addd21)
  • WDA version: 12.2.0
  • Executor: Native (default WDA driver)
  • Device/Simulator: iPhone 16, iOS 18.6 (Simulator)

Additional Context

For projects with many shared setup flows that all call clearState (e.g. Expo apps with per-test seed scripts), this turns "drop in and go" into a meaningful porting effort. The two practical paths today are:

  1. Keep a built .app outside the simulator and pass --app-file everywhere.
  2. Rewrite shared setup flows to drop clearState and reset state via the backend instead.

A clear-in-place implementation (matching Maestro CLI) would be a much easier migration path.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions