Feature: Remove hardcoded index when selecting the correct build target #2707
+16
−18
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 thenpx 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:

And then make it the first build target in the default Xcode scheme:

And then running
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:Checklist
react-native
checkout (instructions).