Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

run-ios --udid <physical device> throws "No simulator available" because the fallback simulator is resolved eagerly

Aperta Adatta ai principianti
#2,826 0 commenti 0 reazioni 0 assegnatari Vedi su GitHub

I maintainer di solito rispondono entro 2 giorni

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
2/5
Tempo stimato
1-3 ore
Idoneità per principianti
84/100
Tipo di issue
Bug
Chiarezza
Specificata chiaramente
Stato di attività
Tranquilla
Stack tecnologico
react-native, typescript
Ambito
cli

Direzione di ricerca

Inizia in createRun.ts intorno alla riga 212 e ispeziona i tre punti di chiamata di fallbackSimulator alle righe 271, 417 e 426. Confrontali con getFallbackSimulator e riproduci il problema con run-ios --udid usando un dispositivo fisico. Il lavoro è completato quando le esecuzioni su dispositivi fisici non risolvono più un simulatore, mentre i percorsi del simulatore continuano a risolvere normalmente il relativo fallback.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

bug report

Environment

npx react-native info
System:
  OS: macOS 26.5
  CPU: (10) arm64 Apple M2 Pro
  Memory: 86.63 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 24.10.0
    path: ~/.nodenv/versions/24.10.0/bin/node
  Yarn:
    version: 1.22.22
    path: /opt/homebrew/bin/yarn
  npm:
    version: 11.6.1
    path: ~/.nodenv/versions/24.10.0/bin/npm
  Watchman:
    version: 2026.07.27.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.16.2
    path: /opt/homebrew/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 25.5
      - iOS 26.5
      - macOS 26.5
      - tvOS 26.5
      - visionOS 26.5
      - watchOS 26.5
  Android SDK: Not Found
IDEs:
  Android Studio: 2026.1 AI-261.26222.65.2613.16025427
  Xcode:
    version: 26.6/17F113
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.20
    path: /usr/bin/javac
  Ruby:
    version: 3.2.2
    path: ~/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli":
    installed: 20.1.2
    wanted: 20.1.2
  react:
    installed: 19.2.3
    wanted: 19.2.3
  react-native:
    installed: 0.85.3
    wanted: 0.85.3
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: true
iOS:
  hermesEnabled: true
  newArchEnabled: true

Description

run-ios --udid <udid-of-a-physical-iPhone> fails before it looks at the device:

error No simulator available with udid "00008140-XXXXXXXXXXXXXXXX"

createRun.ts:212 resolves the fallback simulator before any branch decides whether a simulator is involved:

const fallbackSimulator =
  platformName === 'ios' || platformName === 'tvos'
    ? getFallbackSimulator(args) // throws here
    : devices[0]

It is read only at lines 271, 417 and 426, all simulator paths. Device runs never use it but still pay for it, and getFallbackSimulator throws instead of returning null.

It throws because findMatchingSimulator gets the original args: with args.udid set it returns only on an exact simulator udid match, which a physical device never satisfies. The hardcoded fallback list (iPhone 14/13/12/11) then finds nothing on Xcode 26, which ships the iPhone 17 family.

The same call breaks every run-ios invocation when no simulator runtime is installed, a valid device-only setup: the iPhoneOS SDK ships inside Xcode.app, the runtime is a separate ~8 GB download device builds never touch.

#2795 reworked this branch and kept the eager call.

Suggested fix

Resolve lazily, so only simulator paths can fail on a simulator:

const fallbackSimulator = () =>
  platformName === 'ios' || platformName === 'tvos'
    ? getFallbackSimulator(args)
    : devices[0]

and call fallbackSimulator() at the three call sites. Ran this as a local patch; device and simulator runs both behaved correctly.

Reproducible Demo

Xcode 26, simulators available but none named iPhone 14/13/12/11 and none ever booted (no lastBootedAt in xcrun simctl list --json devices), physical iPhone connected:

npx react-native run-ios --udid <udid-of-the-connected-iPhone>
# error No simulator available with udid "00008140-XXXXXXXXXXXXXXXX"

Only the --udid shape fails:

const {
  getFallbackSimulator
} = require('@react-native-community/cli-platform-apple/build/commands/runCommand/getFallbackSimulator.js')

getFallbackSimulator({}) // OK: iPhone 17 Pro
getFallbackSimulator({ device: 'My iPhone' }) // OK: iPhone 17 Pro
getFallbackSimulator({ udid: '00008140-XXXXXXXXXXXXXXXX' }) // throws

The first two pass only incidentally: with no udid in args the matcher falls through to "first available simulator".

End to end, the real command dies before building:

info Found Xcode workspace "MyApp.xcworkspace"
error No simulator available with udid "00008140-XXXXXXXXXXXXXXXX".
Lingua principale
TypeScript
Stelle
2.9k
Fork
948
Merge medio
10g 19h
PR unite (30g)
1

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di react-native-community/cli

Tutte le issue di react-native-community/cli

Issue simili

Altre issue su TypeScript

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.