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

Abierto Apto para principiantes
#2,820 0 comentarios 0 reacciones 0 asignados Ver en GitHub

Nadie ha tomado este issue todavía.

Evaluación

Dificultad
2/5
Tiempo estimado
1-3 horas
Aptitud para principiantes
75/100
Tipo de issue
Error
Claridad
Bien especificado
Estado de actividad
Tranquilo
Stack tecnológico
react-native, typescript
Área
cli, mobile-dev

Línea de trabajo

Comienza en packages/cli-platform-apple/src/commands/runCommand/runOnSimulator.ts y reproduce npx react-native run-ios con un simulador que ya esté iniciado. Comprueba la ruta de lanzamiento de Simulator.app y la protección existente del estado de inicio; estará terminado cuando los lanzamientos repetidos pongan en primer plano el simulador en ejecución sin mostrar la alerta de inicio.

Escrito por el modelo de indexación a partir del texto del issue.

Descripción

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.

Lenguaje dominante
TypeScript
Estrellas
2.9k
Forks
949
Métricas de merge de PR
Sin PR fusionados en 30 d

Guía de contribución

Abrir la guía de contribución

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de react-native-community/cli

Todos los issues de react-native-community/cli

Issues similares

Más issues de TypeScript

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.