Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix installing step of run-ios command #18700

Closed
wants to merge 1 commit into from
Closed

Conversation

lebedev
Copy link
Contributor

@lebedev lebedev commented Apr 4, 2018

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 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, 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.

Test Plan

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

Related PRs

#17963

Release Notes

[CLI][BUGFIX][local-cli/runIOS/runIOS.js] - Fix failing of run-ios command on install step

@facebook-github-bot facebook-github-bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Apr 4, 2018
@lebedev lebedev changed the title Fix run-ios command Fix installing step of run-ios command Apr 4, 2018
@hramos
Copy link
Contributor

hramos commented Apr 4, 2018

Does this work with Xcode 9.3 as well?

@lebedev
Copy link
Contributor Author

lebedev commented Apr 4, 2018

Does this work with Xcode 9.3 as well?

Good point. Will check.

@lebedev
Copy link
Contributor Author

lebedev commented Apr 4, 2018

@hramos I've made some checks.

With Xcode 9.3 run-ios --no-packager command in a blank project has the same issue: it successfully builds, but fails on install step. And the same proposed fix is applicable to Xcode 9.3 as well.

So it seems that referenced PR that introduced this regression wasn't motivated by Xcode version update.

@grabbou
Copy link
Contributor

grabbou commented Apr 5, 2018

I can confirm this fixes issues on 0.55 branch.

grabbou added a commit that referenced this pull request Apr 5, 2018
@grabbou
Copy link
Contributor

grabbou commented Apr 9, 2018

@facebook-github-bot shipit

@facebook-github-bot facebook-github-bot added the Import Started This pull request has been imported. This does not imply the PR has been approved. label Apr 9, 2018
Copy link
Contributor

@facebook-github-bot facebook-github-bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@grabbou is landing this pull request. If you are a Facebook employee, you can view this diff on Phabricator.

campsafari pushed a commit to exozet/react-native that referenced this pull request Apr 11, 2018
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 facebook#17963 (accepted in facebook@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 facebook#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 facebook#18700

Differential Revision: D7555096

Pulled By: hramos

fbshipit-source-id: d877b867e89256f4356f22781d78308affbb9d9c
@kranzky
Copy link

kranzky commented May 5, 2018

@angly-cat i've been struggling with #7308 for the past few days, eventually digging into code to fix the issue by reverting this change. here's my setup:

Environment:
  OS: macOS High Sierra 10.13.4
  Node: 8.11.1
  Yarn: 1.6.0
  npm: 5.6.0
  Watchman: 4.7.0
  Xcode: Xcode 9.3 Build version 9E145
  Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed)
  react: 16.3.2 => 16.3.2
  react-native: 0.55.3 => 0.55.3

@lebedev
Copy link
Contributor Author

lebedev commented May 5, 2018

@kranzky Do you have default derived data path settings in Xcode? Is it a fresh project that fails for you?

@kranzky
Copy link

kranzky commented May 5, 2018

@angly-cat you're right, I did alter these settings while trying to fix the issue. here are the current settings:

screen shot 2018-05-05 at 15 09 04
screen shot 2018-05-05 at 15 09 21

I tested by creating a new project (TL;DR: it fails with the same error, and Xcode settings are the same):

$ ignite doctor
System
  platform           darwin
  arch               x64
  cpu                8 cores               Intel(R) Core(TM) i7-4870HQ CPU @ 2.50GHz
  directory          /Users/jason

JavaScript
  node               8.8.1        /Users/jason/.nvm/versions/node/v8.8.1/bin/node
  npm                5.5.1        /Users/jason/.nvm/versions/node/v8.8.1/bin/npm
  yarn               1.3.2        /Users/jason/.nvm/versions/node/v8.8.1/bin/yarn

React Native
  react-native-cli   2.0.1

Ignite
  ignite             2.1.0        /usr/local/bin/ignite

Android
  java               1.8.0_40     /usr/bin/java
  android home       -            /usr/local/Cellar/android-sdk/24.1.2

iOS
  xcode              9.3
$ ignite new fubar -b ignite-ir-boilerplate-andross
-----------------------------------------------
  (                  )   (
  )\ )   (        ( /(   )\ )    *   )
 (()/(   )\ )     )\()) (()/(  ` )  /(   (
  /(_)) (()/(    ((_)\   /(_))  ( )(_))  )\
 (_))    /(_))_   _((_) (_))   (_(_())  ((_)
 |_ _|  (_)) __| | \| | |_ _|  |_   _|  | __|
  | |     | (_ | | .` |  | |     | |    | _|
 |___|     \___| |_|\_| |___|    |_|    |___|
-----------------------------------------------

An unfair headstart for your React Native apps.
https://infinite.red/ignite

-----------------------------------------------

🔥 igniting app fubar
✔ using the Infinite Red boilerplate v2 (code name 'Andross')
✔ added React Native 0.55.1 in 26.73s
? Would you like Ignite Development Screens? No
? What vector icon library will you use? none
? What internationalization library will you use? none
? What animation library will you use? none
? Would you like to include redux-persist? No
✔ added ignite-ir-boilerplate-andross in 39.96s
✔ added ignite-standard in 28.57s
✔ configured git
✔ ignited fubar in 102.42s

    Ignite CLI ignited fubar in 102.42s

    To get started:

      cd fubar
      react-native run-ios
      react-native run-android
      ignite --help

    Read the walkthrough at https://github.com/infinitered/ignite-ir-boilerplate-andross/blob/master/readme.md#boilerplate-walkthrough

    Need additional help? Join our Slack community at http://community.infinite.red.

    Now get cooking! 🍽
$ cd fubar/
$ react-native run-ios
Scanning folders for symlinks in /Users/jason/fubar/node_modules (24ms)
Found Xcode project fubar.xcodeproj
Building using "xcodebuild -project fubar.xcodeproj -configuration Debug -scheme fubar -destination id=E31F5241-449C-4640-871E-BD9920B19936 -derivedDataPath build"
User defaults from command line:

    IDEDerivedDataPathOverride = /Users/jason/fubar/ios/build

=== BUILD TARGET yoga OF PROJECT React WITH CONFIGURATION Debug ===

...

** BUILD SUCCEEDED **

The following commands produced analyzer issues:
	Analyze Base/RCTModuleMethod.mm normal x86_64
(1 command with analyzer issues)

Installing build/Build/Products/Debug-iphonesimulator/fubar.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/fubar.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
$ find ios/build -maxdepth 2 -type d
ios/build
ios/build/Products
ios/build/Products/Debug-iphonesimulator
ios/build/ModuleCache.noindex
ios/build/ModuleCache.noindex/3BT9TN6YNRIGI
ios/build/ModuleCache.noindex/3FG37Z01Q2LE4
ios/build/ModuleCache.noindex/2IXK0Q42E8TE4
ios/build/ModuleCache.noindex/95XU5OL6KPB
ios/build/ModuleCache.noindex/6WNKY0PO49G5
ios/build/ModuleCache.noindex/N5XY4JVU7EV0
ios/build/ModuleCache.noindex/2ZAQIWUHWI4HV
ios/build/ModuleCache.noindex/CNBYCCM3SNNA
ios/build/Build
ios/build/Build/Index
ios/build/Intermediates
ios/build/Intermediates/RCTText.build
ios/build/Intermediates/fubar.build
ios/build/Intermediates/RCTAnimation.build
ios/build/Intermediates/RCTActionSheet.build
ios/build/Intermediates/RCTGeolocation.build
ios/build/Intermediates/RCTImage.build
ios/build/Intermediates/RCTNetwork.build
ios/build/Intermediates/RCTBlob.build
ios/build/Intermediates/React.build
ios/build/Intermediates/RCTVibration.build
ios/build/Intermediates/RCTSettings.build
ios/build/Intermediates/RCTLinking.build
ios/build/Intermediates/RCTWebSocket.build
$ open ios/fubar.xcodeproj

Confirmed it fails with a new project, and that the Xcode settings of the new project are the same as what I was using.

@kranzky
Copy link

kranzky commented May 5, 2018

I'm wondering whether some developers have their filesystem set to case-sensitive filenames? that may explain why ios/build and ios/Build are the same for me, while others see a Build directory being created in ios/build (presumable because ios/Build does not exist with case-sensitive filenames)? The Mac filesystem supports both, with case-insensitive being the default afaik.

If that's the issue, changing the derivedDataPath flag from build to Build may fix it for everyone.

@lebedev
Copy link
Contributor Author

lebedev commented May 5, 2018

I tested by creating a new project (TL;DR: it fails with the same error, and Xcode settings are the same):

Have you tried creating a new project using react-native init? Or create-react-native-app?

(presumable because ios/Build does not exist with case-sensitive filenames)

My macOS is case-insensitive and it still creates paths with two "build"s. These are different "build"s. You can check the first post in this PR with my explanation of where they come from.

Can you show the bottom path of that window, the most interesting part?

Check the paths I have:

As you can see, Products path is prepended by Build, Intermediates path is prepended by Build too, and Index Datastore path isn't.

ios/build/Build
ios/build/Build/Index

But for you, it's vise versa? First two are not prepended, but the third is. That's strange.

@kranzky
Copy link

kranzky commented May 5, 2018

same error with react-native init, but my paths are different; i've modified the build location in Xcode preferences. i don't remember doing that.

$ react-native init fubar2
This will walk you through creating a new React Native project in /Users/jason/fubar2
Using yarn v1.6.0
Installing react-native...

...

✨  Done in 10.68s.
To run your app on iOS:
   cd /Users/jason/fubar2
   react-native run-ios
   - or -
   Open ios/fubar2.xcodeproj in Xcode
   Hit the Run button
To run your app on Android:
   cd /Users/jason/fubar2
   Have an Android emulator running (quickest way to get started), or a device connected
   react-native run-android
$ cd fubar2
$ react-native run-ios
Scanning folders for symlinks in /Users/jason/fubar2/node_modules (11ms)
Found Xcode project fubar2.xcodeproj
Building using "xcodebuild -project fubar2.xcodeproj -configuration Debug -scheme fubar2 -destination id=E31F5241-449C-4640-871E-BD9920B19936 -derivedDataPath build"

...

** BUILD SUCCEEDED **

The following commands produced analyzer issues:
	Analyze Base/RCTModuleMethod.mm normal x86_64
(1 command with analyzer issues)

Installing build/Build/Products/Debug-iphonesimulator/fubar2.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/fubar2.app/Info.plist
Print: Entry, ":CFBundleIdentifier", Does Not Exist
$ open ios/fubar2.xcodeproj

screen shot 2018-05-05 at 16 34 37
screen shot 2018-05-05 at 16 35 04

@lebedev
Copy link
Contributor Author

lebedev commented May 5, 2018

i've modified the build location in Xcode preferences. i don't remember doing that.

I've seen some people proposing that as a fix to the issue.

Mine settings are these (I believe that's the defaults):

@kranzky
Copy link

kranzky commented May 5, 2018

@angly-cat great, changing my preference to "unique" fixes the issue. thanks for your help 👍

@lebedev
Copy link
Contributor Author

lebedev commented May 5, 2018

@kranzky You're welcome 😸

@jimcamut
Copy link

jimcamut commented May 5, 2018

As a temporary solution (just to get it up and running) I changed line 249 of local-cli/runIOS/runIOS.js to default to port 8081.

function getProcessOptions(launchPackager, port = 8081) {
  if (launchPackager) {
    return {
      env: { ...process.env, RCT_METRO_PORT: port }
    };
  }

  return {
    env: { ...process.env, RCT_NO_LAUNCH_PACKAGER: true },
  };
}

macdoum1 pushed a commit to macdoum1/react-native that referenced this pull request Jun 28, 2018
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 facebook#17963 (accepted in facebook@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 facebook#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 facebook#18700

Differential Revision: D7555096

Pulled By: hramos

fbshipit-source-id: d877b867e89256f4356f22781d78308affbb9d9c
grabbou pushed a commit to react-native-community/cli that referenced this pull request Sep 26, 2018
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 facebook/react-native@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 facebook/react-native#18700

Differential Revision: D7555096

Pulled By: hramos

fbshipit-source-id: d877b867e89256f4356f22781d78308affbb9d9c
@Ethan0007
Copy link

Ethan0007 commented May 29, 2019

Hi,

I'm having the same issue I'm using the following:
"react-native": "^0.59.8",
Xcode 10.1

Screen Shot 2019-05-29 at 6 14 02 PM

Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. Import Started This pull request has been imported. This does not imply the PR has been approved. Platform: iOS iOS applications.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants