Skip to content

Conversation

jenskuhrjorgensen
Copy link

@jenskuhrjorgensen jenskuhrjorgensen commented Aug 27, 2025

Summary

In our app we have some old static lib targets that need to be built before the actual application target. This means that our app target is not the first one in the targets list in the Xcode scheme which in turn means let selectedTarget = targets[0] is not sophisticated enough to find the actual app target. We could add --target <MY_TARGET> to the npx react-native run-ios but I believe this PR improves the functionality a bit.

This PR fixes this by only looking at targets with WRAPPER_EXTENSION === 'app' which was also partially done before but just at a later stage.

Test Plan

You can test this in a vanilla RN project by adding e.g. a "Static" library target:
Screenshot 2025-08-27 at 12 27 16

And then make it the first build target in the default Xcode scheme:
Screenshot 2025-08-27 at 12 26 37

And then running

npx react-native run-ios

Before this PR, this would fail because the application target is now put in targets[1].

If you have multiple application targets you can test out the --target parameter like this:

npx react-native run-ios --target "<YOUR_APP_TARGET>"

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

@jenskuhrjorgensen jenskuhrjorgensen changed the title Fix: Remove hardcoded index when selecting the correct build target Feature: Remove hardcoded index when selecting the correct build target 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