Skip to content

Conversation

jenskuhrjorgensen
Copy link
Contributor

@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
@jenskuhrjorgensen
Copy link
Contributor Author

jenskuhrjorgensen commented Oct 1, 2025

Hi @thymikee
Is there a chance you will pick this up soon? 🙏 Or are you awaiting something from me?

Comment on lines +42 to +48
const isDevice = args.device;
let destination = '';
if (udid) {
destination = `id=${udid}`;
} else if (isDevice) {
destination = 'generic/platform=iOS';
} else if (mode === 'Debug') {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you move this logic further down so it's not tied to the simulatorDest logic below?

Copy link
Contributor Author

@jenskuhrjorgensen jenskuhrjorgensen Oct 1, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't want to mess too much around with the previous logic, so my if-else is more or less a more verbose version of the previous ternary condition with the addition of an isDevice check.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

previous logic would execute this branch regardless of the mode. I'd like to keep that behavior

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like this?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If not please provide a code suggestion and I would be happy to apply it :)

@jenskuhrjorgensen
Copy link
Contributor Author

@thymikee For some reason there were some lint issues in files that I didn't touch in this PR. However, I fixed them to make the lint CI pass. The E2E tests that are failing does not seem to be related to this PR.

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.

2 participants