React-native: [cli] `react-native run-ios --scheme XXX` work incorrectly

Created on 26 Sep 2016  路  14Comments  路  Source: facebook/react-native

I have two targets/schemes in the iOS project: one is for production; the other one is for staging.

I tried to run react-native run-ios with different scheme params for --scheme, but it always launch the production target even choosing staging scheme.

$ react-native run-ios --scheme MyAppProduction
$ react-native run-ios --scheme MyAppStaging

The xcodebuild works correctly:

$ "xcodebuild -workspace MyApp.xcworkspace -scheme MyAppStaging -destination id=16ABE1A9-XXXX-XXXX-XXXX-650DA9457D6C -derivedDataPath build"

but after build succeeded, the install wrong app and launch wrong App ID.

// Build the MyAppStaging.app
Touch build/Build/Products/Debug-iphonesimulator/MyAppStaging.app

...

** BUILD SUCCEEDED **

// Install and launch MyApp.app (production)
Installing build/Build/Products/Debug-iphonesimulator/MyApp.app
Launching com.MyApp.XXX.XXX
com.MyApp.XXX.XXX: 9851
Locked

Most helpful comment

What's the status of this bug? It's May 19th 2017 at v0.44 and this is still happening.

FWIW, react-native link also only cares about the main scheme, and not other schemes.

All 14 comments

Also want to know the correct way to use react-native run-ios --scheme. Is there any documentation?

I am having the same issue. It is because the CLI is coded incorrectly. While the scheme that you pass will be built, it will not actually push the equivalent scheme to the simulator/device.

The problem is on line 91 of the CLI runIOS.js:

const appPath = `build/Build/Products/Debug-iphonesimulator/${inferredSchemeName}.app`;

Two problems with this:

  1. "Debug-iphonesimulator" is hardcoded and shouldn't be. A non-default scheme would be in a different directory.
  2. inferredSchemeName is still passed, even if scheme was passed to the command.

You can still build different schemes with a React-Native project through Xcode though.

Just to let everyone know, this appears to be fixed in master via this commit, so hopefully we see it in one of the upcoming RN releases.

What's the status of this bug? It's May 19th 2017 at v0.44 and this is still happening.

FWIW, react-native link also only cares about the main scheme, and not other schemes.

FWIW, react-native link also only cares about the main scheme, and not other schemes.

@bmcmillan is this true? that's a really serious problem, if possible, would you mind telling me what workaround are you using for that? Schemes are absolutely necessary...

@eddnav yes, absolutely true. The workaround is to do all of it manually. I have 4 other schemes, so that's a PITA.

Ran into this issue today when starting up a new project with the latest version of React Native (0.45.1). I had previously been using 0.41.2 and had a separate MyAppDev scheme that was duplicated from the default MyApp scheme and had some minor changes, and everything was all working fine. Now with 0.45.1, when I try to run in a simulator using react-native run-ios --scheme MyAppDev, I get the following error:

Installing build/Build/Products/Debug-iphonesimulator/MyAppDev.app
An error was encountered processing the command (domain=NSPOSIXErrorDomain, code=2):
Failed to install the requested application
An application bundle was not found at the provided path.
Provide a valid path to the desired application bundle.
Print: Entry, ":CFBundleIdentifier", Does Not Exist

Command failed: /usr/libexec/PlistBuddy -c Print:CFBundleIdentifier build/Build/Products/Debug-iphonesimulator/MyAppDev.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist

I believe the reason it's failing is it mistakenly thinks it should be using MyAppDev.app when it is supposed to use MyApp.app. I think it might be doing this because of the code at https://github.com/facebook/react-native/blob/master/local-cli/runIOS/runIOS.js#L97 where it falls back to the scheme name?

@jordanmkoncz I got exactly the same problem, working with schemes seems not to work in this update. building via Xcode GUI does not work either for me.

Was there any solution to this? Running react-native run-ios --scheme xxx did not seem to work for me.

@jordanmkoncz @hdchan I ran across the same issue today and it looks like it had been fixed: https://github.com/facebook/react-native/commit/242d29d37486054ee31304db85660fca43027a1c

Upgrading to v0.46 should fix it.

@jkimbo did it work for you? That PR only mentions the "--configuration" flag, but maybe it also affects "--scheme" (?)

@southerneer yep it worked for scheme too. I have a Staging configuration setup as well as a MyApp Staging scheme so the command that works is:
react-native run-ios --scheme "MyApp Staging" --configuration Staging

Duplicate of #14447

Duplicate of #14423

Was this page helpful?
0 / 5 - 0 ratings