## TL;DR

A rebooted simulator can come back with a new UDID or sit in a half-booted state while Detox still looks for the old device id. List the simulators, boot the right one explicitly, wait until the boot completes, and clear Detox's cached device selection if it persists. Then the run finds its device.

## Error

```text
detox device not found after simulator reboot: how to fix
```

Detox fails with device not found immediately after the simulator reboot step; the simulator exists in Xcode.

## Steps

1. List simulators and their states with xcrun simctl list devices. Expected output: you see the target simulator and whether it is Shutdown, Booted, or stuck in between.
2. Boot it explicitly with xcrun simctl boot plus the device UDID, then wait with xcrun simctl bootstatus plus the UDID in blocking mode. Expected output: the device reports as fully booted.
3. If Detox still cannot find it, the UDID changed across the reboot; update the device query in the Detox config to match by name and OS instead of a hardcoded UDID. Expected output: config selects the simulator by stable attributes.
4. Clear Detox build and device caches if a stale selection persists. Expected output: Detox re-discovers devices from scratch.
5. Re-run the test on the freshly booted simulator. Expected output: Detox connects and the suite starts.

## When to use

- Detox reports device not found right after a simulator reboot.
- CI reboots simulators between jobs and tests then fail.
- The simulator exists but Detox picks a different one.

## When not to use

- The simulator was deleted (recreate it first).
- Android emulator issues (different toolchain, different fix).
- Detox cannot find any simulator ever (check the Xcode and simctl setup).

## Variant phrasings

### Device stuck in Shutdown state

A reboot that never finished leaves the device Shutdown; boot it explicitly rather than trusting Detox to do it.

### Detox picks the wrong simulator

Name plus OS matching beats UDID matching across reboots; pin the query, not the id.

### CI simulator never boots

CI images sometimes need the simulator runtime installed or the bootstatus wait added; check the image contents.

## Why it happens

Detox resolves the target device once and caches the choice, while a reboot can change the simulator's identity or leave it mid-boot. The mismatch is between Detox's cached device record and the simulator's actual post-reboot state.

## Edge cases

- Multiple simulators with the same name and OS version make name matching ambiguous; include the OS version in the query.
- A reboot during a test run (not before) also kills the Detox connection; handle it as a run restart, not a device lookup.
- Erasing the simulator between lookup and boot changes its state; avoid erasing in that window.

## Provenance

Resolved from the public thread: https://vectle.com/posts/pst_6-XdKKUgjvYNClMURO8Nzw
