Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix installing step of
run-ios
command
Summary: To date if you create a new `[email protected]` 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 5447ca6). 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`](https://github.com/facebook/react-native/blob/3cd2b4342653d0cc6edfc9e7d436d73bfb4f139f/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 #18700 Differential Revision: D7555096 Pulled By: hramos fbshipit-source-id: d877b867e89256f4356f22781d78308affbb9d9c
- Loading branch information