react-native-community / react-native-community/cli

run-ios: "Unable to boot device in current state: Booted" alert when the simulator is already booted

Open Beginner friendly
#2,820 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
2.9k
Forks
949
PR merge metrics
No merged PRs in 30d

Description

Environment

  • @react-native-community/cli: 20.2.0 (also reproduces on main, latest commit 9013a48 at time of writing)
  • OS: macOS (Apple Silicon)
  • Xcode: stable (not Xcode 27 beta) — Simulator.app present at $(xcode-select -p)/Applications/Simulator.app, so the run-ios code path takes the Simulator.app branch (not the DeviceHub branch added in #2806)

Description

Running run-ios against a simulator that is already booted pops a modal alert from Simulator.app reading:

Unable to boot device in current state: Booted

before the build proceeds. The alert must be dismissed manually and it recurs on every re-launch until the simulator is shut down. The build itself still succeeds. A cold first launch (no booted device) is unaffected.

Root cause

In packages/cli-platform-apple/src/commands/runCommand/runOnSimulator.ts, the open Simulator.app --args -CurrentDeviceUDID <udid> call runs unconditionally, before the simulator.state !== 'Booted' guard:

if (fs.existsSync(simulatorApp)) {
  child_process.execFileSync('open', [
    simulatorApp,
    '--args',
    '-CurrentDeviceUDID',
    simulator.udid,
  ]);
} else if (fs.existsSync(deviceHubApp)) {
  ...
}

if (simulator.state !== 'Booted') {
  bootSimulator(simulator);
}

Passing -CurrentDeviceUDID for an already-booted device makes Simulator.app re-attempt a boot of that device, which CoreSimulator rejects with the exact string Unable to boot device in current state: Booted. Simulator.app surfaces that rejection as a modal alert.

The later simulator.state !== 'Booted' guard correctly skips the explicit xcrun simctl boot, but it is too late — the open ... --args -CurrentDeviceUDID call has already provoked the dialog. The DeviceHub branch (Xcode 27+) is unaffected, since it never passes -CurrentDeviceUDID.

Fix

Only pass -CurrentDeviceUDID when the device is not already booted; when it is booted, just bring the running Simulator.app to the foreground. A PR is incoming.

Reproducible Demo

  1. npx react-native run-ios — boots a fresh simulator; no alert.
  2. Leave the simulator booted (don't shut it down).
  3. npx react-native run-ios again → the "Unable to boot device in current state: Booted" modal appears over Simulator.app.
  4. Click OK to dismiss; the build continues normally.
  5. Reproduces on every subsequent run-ios until the simulator is shut down.

Expected: Step 3 should just foreground Simulator.app and install/launch the app — no alert — same as the clean first launch.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in packages/cli-platform-apple/src/commands/runCommand/runOnSimulator.ts and reproduce npx react-native run-ios with a simulator that is already booted. Check the Simulator.app launch path and the existing boot-state guard; done means repeated launches foreground the running simulator without showing the boot alert.

Written by the indexing model from the issue text.

Assessment

Tech stack
react-native, typescript
Domain
cli, mobile-dev
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
75/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.