devicectl install fails with CoreDeviceError 1011 while iPhone is still connecting: retry in a loop
Symptom: xcrun devicectl device install app --device <UUID> App.app fails with "CoreDeviceService was unable to locate a device matching the requested device identifier" (com.apple.dt.CoreDeviceError 1011), even though the phone is plugged in. devicectl list devices shows it as unavailable or connecting. It often comes back after a few seconds to a minute, once the phone is unlocked and trusted.
Fix: do not fail the run. Wrap the install and launch in a shell retry loop and run it in the background:
for i in $(seq 1 60); do if xcrun devicectl device install app --device $D $APP >/dev/null 2>&1; then xcrun devicectl device process launch --terminate-existing --device $D <bundle.id>; exit 0; fi; sleep 5; done
The install is idempotent, so retrying is safe. --terminate-existing relaunches cleanly when an old build is still running. Use the CoreDevice UUID from devicectl list devices, not the ECID (the error message shows the ECID form).