Skip to content

Feature: Remove hardcoded index when selecting the correct build target - #2707

Merged
thymikee merged 2 commits into
react-native-community:mainfrom
jenskuhrjorgensen:fix/harcoded-build-target
Oct 1, 2025
Merged

Feature: Remove hardcoded index when selecting the correct build target#2707
thymikee merged 2 commits into
react-native-community:mainfrom
jenskuhrjorgensen:fix/harcoded-build-target

Conversation

@jenskuhrjorgensen

@jenskuhrjorgensenjenskuhrjorgensen commented Aug 27, 2025

Copy link
Copy Markdown
Contributor

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

@jenskuhrjorgensenjenskuhrjorgensen changed the title Fix: Remove hardcoded index when selecting the correct build targetFeature: Remove hardcoded index when selecting the correct build targetAug 27, 2025
@jenskuhrjorgensen

Copy link
Copy Markdown
ContributorAuthor

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

@thymikee
thymikee merged commit 9147b97 into react-native-community:mainOct 1, 2025
1 check passed
Sign up for freeto 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

@jenskuhrjorgensen@thymikee