Adding Build Target and Scheme causes run-ios
to fail
#14907
Labels
Resolution: Locked
This issue was locked by the bot.
run-ios
to fail
#14907
Is this a bug report?
Yes
Have you read the Bugs section of the Contributing to React Native Guide?
Yes
Environment
react-native -v
: react-native-cli: 2.0.1, react-native: 0.46.1node -v
: v6.10.2npm -v
: 3.10.10yarn --version
(if you use Yarn): 0.24.6Then, specify:
Steps to Reproduce
react-native init rnclifail
)rnclifail.xcodeproj
in Xcodernclifail
from list and click the setings iconduplicate
rnclifail
project in left side panelrnclifail
) and click Duplicaternclifail copy
tornclifail2
, and the change the bundle identifier postfix so it'srnclifail2
instead ofrnclifail-copy
.rnclifail2
and enable Shared so it's similar to the originalrnclifail
Edit
rnclifail2.app
Release
react-native bundle --platform ios --dev false --bundle-output iOS/main.jsbundle --entry-file index.ios.js
.main.jsbundle
andmain.jsbundle.meta
into thernclifail
group folder in XCode. SelectCopy items if needed
, selectCreate groups
and select bothrnclifail
andrnclifail2
in Add to targets.react-native run-ios --scheme rnclifail --configuration Debug
. It should pass and installrnclifail.app
which is expected behaviour. See output below.react-native run-ios --scheme rnclifail2 --configuration Release
. It should pass too but it installedrnclifail.app
instead ofrnclifail2.app
. See output below.Output from Step 19
Output from Step 20
Expected Behavior
The
rncliapp2.app
would get deployed.Actual Behavior
The
rncliapp.app
got built and deployed.Reproducible Demo
yarn install
Fix
Have analysed the build output and logs and found that the block starting at 158 in
/local-cli/runIOS/runIOS.js
(https://github.com/facebook/react-native/blob/master/local-cli/runIOS/runIOS.js#L158) contains the error:The following is the current code:
Problem 1
This assumes a build output where a line exists such that:
exists, which does not happen to be true. The actual build output (gotten by
console.log(buildOutput)
shows that the line we expect is actually without the apostrophes:What happens is that there is no matched
productNameMatch
andresolve()
is called which results inappName
beingnull
on line 97 (https://github.com/facebook/react-native/blob/master/local-cli/runIOS/runIOS.js#L97), and the CLI defaults to using theinferredSchemeName
which is wrong.Problem 2
The current code assumes that only one instance of
export FULL_PRODUCT_NAME=<APP_NAME>.app
will appear in the build output, which may not be true in a custom build scheme, however according to Xcode behaviour, we can expect the final product of each Build Scheme to be the last listed. We can fix this by not assuming any length and instead taking the last index of the matches.Solution
The fix would be to change the block of code to the following block, which would retrieve all instances of
export FULL_PRODUCT_NAME=<APP_NAME>.app
and use the last one:Have already fixed this in my local repo so that I can get the correct files built, and will submit a PR when I can.
The text was updated successfully, but these errors were encountered: