Skip to content

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

Description

@maxKimoby

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".

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions