Skip to content

Conversation

jenskuhrjorgensen
Copy link

@jenskuhrjorgensen jenskuhrjorgensen commented Aug 27, 2025

Summary

If you run

npx react-native build-ios --device

It will result in Xcodebuild building for the simulator instead of a physical iOS device:

xcodebuild ... -destination generic/platform=iOS Simulator

This PR fixes that so the outcome instead becomes

xcodebuild ... -destination generic/platform=iOS

This is achieved by fixing the destination in buildProject when running with device arg but no specific UDID or args.destination. Also move device property from the run command's FlagsT to the build command's BuildFlags because that is where it was actually described (inside getBuildOptions).

See more discussion with @thymikee here:
#2517 (comment)

This PR is largely a restructuring of the existing complex ternary conditions into a more readable if-else-condition with the addition of a missing check for isDevice.

Test Plan

Unfortunately, there are no tests for the --device option (which is probably also why this feature broke at some point), but I see it as out of scope for this PR to correct that, so testing will have to be done manually by connecting a physical iOS device and then run

npx react-native build-ios --device

And validate that it actually builds, installs and launches the app on the iOS device.

Checklist

  • Documentation is up to date.
  • Follows commit message convention described in CONTRIBUTING.md.
  • For functional changes, my test plan has linked these CLI changes into a local react-native checkout (instructions).

Fix: Fix destination in buildProject when running with device arg but no specific UDID or args.destination
@jenskuhrjorgensen jenskuhrjorgensen changed the title Fix destination in `buildproject Fix destination in buildProject Aug 27, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant