react-native/local-cli
Angly Cat 0934c1778f Fix installing step of `run-ios` command
Summary:
To date if you create a new `react-native@0.55.0` project and try to build/run it for iOS via CLI, e.g. by running:

```
$ react-native init test
$ cd test
$ react-native run-ios --no-packager
```

the build would succeed, but installing will fail afterwards:

```
** BUILD SUCCEEDED **

Installing Build/Products/Debug-iphonesimulator/test.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/Products/Debug-iphonesimulator/test.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
```

This fail happens because `/usr/libexec/PlistBuddy` can't find `Info.plist` file at the provided path.

This is a regression introduced by changes from PR #17963 (accepted in 5447ca6707). If you execute test plan from that PR, it would fail.

As per why:

By default, `run-ios` process's working directory is `$PROJECT_DIR/ios`.

According to [this line in `runIOS.js`](3cd2b43426/local-cli/runIOS/runIOS.js (L184)), `xcodebuild` places all artifacts in `build` directory.

And the default Xcode paths for products is `Build/Products` (at least of Xcode 9.2 which I use, and Xcode 9.3 which I tested this with also).

So, the required `Info.plist` file is actually being created at `$PROJECT_DIR/ios/build/Build/Products/Debug-iphonesimulator/test.app/Info.plist` (with double `build`, the first from `derivedDataPath` key, the second from default products path). Relatively to `run-ios` process's working directory, the path of the file is `build/Build/Products/Debug-iphonesimulator/test.app/Info.plist`.

PR #17963 changed correct path to incorrect, thus introducing this regression.

If changes from that PR are reverted, CLI doesn't fail on install step.

I catch this error on both existing project and a freshly created test project. I can build/run an app from Xcode just fine, but running from CLI still would fail. The other workaround is to change path of products artifacts in Xcode, which is user settings and therefore can't be commited to a project's repo with VCS.

Run:

```
$ react-native init test
$ cd test
$ react-native run-ios --no-packager
```

Ensure that it doesn't fail on install step and produce output similar to this:

```
Installing build/Build/Products/Debug-iphonesimulator/test.app
Launching org.reactjs.native.example.test
```

[CLI][BUGFIX][local-cli/runIOS/runIOS.js] - Fix failing of `run-ios` command on install step
Closes https://github.com/facebook/react-native/pull/18700

Differential Revision: D7555096

Pulled By: hramos

fbshipit-source-id: d877b867e89256f4356f22781d78308affbb9d9c
2018-04-09 12:43:53 -07:00
..
__mocks__ Update license headers for MIT license 2018-02-16 18:31:53 -08:00
__tests__ @allow-large-files Upgrade xplat/js to Flow v0.66 2018-02-16 20:24:57 -08:00
bundle Adds an experimental hook for custom resolutions 2018-04-05 09:00:04 -07:00
core Update additional license headers 2018-03-08 12:10:14 -08:00
dependencies Remove optional parameter from server and enforce empty list everywhere 2018-03-01 05:33:05 -08:00
eject Update license headers for MIT license 2018-02-16 18:31:53 -08:00
generator Update license headers for MIT license 2018-02-16 18:31:53 -08:00
info Update license headers for MIT license 2018-02-16 18:31:53 -08:00
init Update license headers for MIT license 2018-02-16 18:31:53 -08:00
install Update license headers for MIT license 2018-02-16 18:31:53 -08:00
library Use sync fs.mkdir 2018-02-25 21:49:28 -08:00
link While linking plugin ask for params only once 2018-03-20 14:49:55 -07:00
logAndroid Update license headers for MIT license 2018-02-16 18:31:53 -08:00
logIOS Update license headers for MIT license 2018-02-16 18:31:53 -08:00
runAndroid Update license headers for MIT license 2018-02-16 18:31:53 -08:00
runIOS Fix installing step of `run-ios` command 2018-04-09 12:43:53 -07:00
server Adds an experimental hook for custom resolutions 2018-04-05 09:00:04 -07:00
templates Inline and fix proguard rules 2018-04-05 17:34:53 -07:00
upgrade Update license headers for MIT license 2018-02-16 18:31:53 -08:00
util Fix #17610, Add fixtures to metro blacklist 2018-02-16 20:48:15 -08:00
.npmignore npmignore: ignore tests and fixtures 2018-02-27 08:42:14 -08:00
cli.js Update license headers for MIT license 2018-02-16 18:31:53 -08:00
cliEntry.js Update license headers for MIT license 2018-02-16 18:31:53 -08:00
commands.js Update license headers for MIT license 2018-02-16 18:31:53 -08:00
setup_env.bat Update license headers for MIT license 2018-02-16 18:31:53 -08:00
setup_env.sh Update license headers for MIT license 2018-02-16 18:31:53 -08:00
wrong-react-native.js Update license headers for MIT license 2018-02-16 18:31:53 -08:00