cli icon indicating copy to clipboard operation
cli copied to clipboard

react-native run-ios --device not working with XCode 12.5 CLI tools

Open cbargren opened this issue 5 years ago • 17 comments

Environment

System:
    OS: macOS 11.3
    CPU: (8) x64 Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
    Memory: 626.05 MB / 16.00 GB
    Shell: 5.8 - /bin/zsh
  Binaries:
    Node: 14.2.0 - /var/folders/34/_v0h6lqn0x17yx6pppvqrnbmcjbc20/T/yarn--1619714124765-0.3284344217580091/node
    Yarn: 1.22.10 - /var/folders/34/_v0h6lqn0x17yx6pppvqrnbmcjbc20/T/yarn--1619714124765-0.3284344217580091/yarn
    npm: 6.14.4 - ~/.nvm/versions/node/v14.2.0/bin/npm
    Watchman: 4.9.0 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.10.1 - /usr/local/bin/pod
  SDKs:
    iOS SDK:
      Platforms: iOS 14.5, DriverKit 20.4, macOS 11.3, tvOS 14.5, watchOS 7.4
    Android SDK:
      API Levels: 23, 28, 29
      Build Tools: 28.0.3, 29.0.2, 29.0.3
      System Images: android-28 | Intel x86 Atom_64, android-29 | Google APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom
      Android NDK: Not Found
  IDEs:
    Android Studio: 4.1 AI-201.8743.12.41.7042882
    Xcode: 12.5/12E262 - /usr/bin/xcodebuild
  Languages:
    Java: 1.8.0_252 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.1 => 17.0.1 
    react-native: 0.64.0 => 0.64.0 
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Description

After upgrading to the latest version of Xcode (12.5), I can no longer run my react-native project on a physical device. Running react-native run-ios --device=X always results in an error and a message that there are no available devices to run on:

image

I've tracked the issue down to this line. It seems that xcrun xctrace list devices no longer outputs to stderr:

image

tail error => empty, tail out => list of devices. Changing the above line to stdout instead of stderr fixes the issue locally for me.

Reproducible Demo

This should be reproducible on any react-native project when running XCode 12.5, but if I'm mistaken, let me know and I'll try to put together a minimal demo.

cbargren avatar Apr 29 '21 17:04 cbargren

I ran into the same issue, and found the same solution as you. Temporarily fixing with the following patch-package patch: @react-native-community+cli-platform-ios+5.0.1-alpha.2.patch

diff --git a/node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js b/node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js
index ac4cd9f..ce330d8 100644
--- a/node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js
+++ b/node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js
@@ -128,7 +128,7 @@ function runIOS(_, ctx, args) {
   let devices;
 
   try {
-    devices = (0, _parseXctraceIOSDevicesList.default)(_execa().default.sync('xcrun', ['xctrace', 'list', 'devices']).stderr);
+    devices = (0, _parseXctraceIOSDevicesList.default)(_execa().default.sync('xcrun', ['xctrace', 'list', 'devices']).stdout);
   } catch (e) {
     _cliTools().logger.warn('Support for Xcode 11 and older is deprecated. Please upgrade to Xcode 12.');
 

dburdan avatar Apr 29 '21 18:04 dburdan

@dburdan mind sending a PR? :)

thymikee avatar Apr 30 '21 09:04 thymikee

I submitted a pull request for this. Ran into this issue after updating to Xcode 12.5.

thang2162 avatar Apr 30 '21 15:04 thang2162

I ran into the same issue, and found the same solution as you. Temporarily fixing with the following patch-package patch: @react-native-community+cli-platform-ios+5.0.1-alpha.2.patch

diff --git a/node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js b/node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js
index ac4cd9f..ce330d8 100644
--- a/node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js
+++ b/node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js
@@ -128,7 +128,7 @@ function runIOS(_, ctx, args) {
   let devices;
 
   try {
-    devices = (0, _parseXctraceIOSDevicesList.default)(_execa().default.sync('xcrun', ['xctrace', 'list', 'devices']).stderr);
+    devices = (0, _parseXctraceIOSDevicesList.default)(_execa().default.sync('xcrun', ['xctrace', 'list', 'devices']).stdout);
   } catch (e) {
     _cliTools().logger.warn('Support for Xcode 11 and older is deprecated. Please upgrade to Xcode 12.');
 

For others waiting for this fix in a new release of the cli, apply the above patch by placing it in a file called @react-native-community+cli-platform-ios+5.0.1-alpha.2.patch in your project folder, and running:

patch -p1 < @react-native-community+cli-platform-ios+5.0.1-alpha.2.patch

fredefl avatar May 06 '21 12:05 fredefl

I ran into the same issue, and found the same solution as you. Temporarily fixing with the following patch-package patch: @react-native-community+cli-platform-ios+5.0.1-alpha.2.patch

diff --git a/node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js b/node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js
index ac4cd9f..ce330d8 100644
--- a/node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js
+++ b/node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js
@@ -128,7 +128,7 @@ function runIOS(_, ctx, args) {
   let devices;
 
   try {
-    devices = (0, _parseXctraceIOSDevicesList.default)(_execa().default.sync('xcrun', ['xctrace', 'list', 'devices']).stderr);
+    devices = (0, _parseXctraceIOSDevicesList.default)(_execa().default.sync('xcrun', ['xctrace', 'list', 'devices']).stdout);
   } catch (e) {
     _cliTools().logger.warn('Support for Xcode 11 and older is deprecated. Please upgrade to Xcode 12.');
 

For others waiting for this fix in a new release of the cli, apply the above patch by placing it in a file called @react-native-community+cli-platform-ios+5.0.1-alpha.2.patch in your project folder, and running:

patch -p1 < @react-native-community+cli-platform-ios+5.0.1-alpha.2.patch

I'm getting patch unexpectedly ends in middle of line after running the command. I pasted the diff into the new file with no changes. Anyone know why?

aryanm5 avatar May 16 '21 02:05 aryanm5

Hello, Not working for me:

  • Latest release: 5.0.1-alpha.2
  • iOS: 12.5

MBach avatar May 27 '21 15:05 MBach

5.0.1-alpha.2 was published before PR #1407 was merged.

I recommend you consider trying the 6.0.0-rc.0 or @react-native-community/cli@next version from npm which should include the bugfix.

brody2consult avatar May 27 '21 17:05 brody2consult

Hello, 6.0.0-rc.0 was not working for me ;)

minyoung-jun avatar May 28 '21 06:05 minyoung-jun

I ran into the same issue, and found the same solution as you. Temporarily fixing with the following patch-package patch: @react-native-community+cli-platform-ios+5.0.1-alpha.2.patch

diff --git a/node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js b/node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js
index ac4cd9f..ce330d8 100644
--- a/node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js
+++ b/node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js
@@ -128,7 +128,7 @@ function runIOS(_, ctx, args) {
   let devices;
 
   try {
-    devices = (0, _parseXctraceIOSDevicesList.default)(_execa().default.sync('xcrun', ['xctrace', 'list', 'devices']).stderr);
+    devices = (0, _parseXctraceIOSDevicesList.default)(_execa().default.sync('xcrun', ['xctrace', 'list', 'devices']).stdout);
   } catch (e) {
     _cliTools().logger.warn('Support for Xcode 11 and older is deprecated. Please upgrade to Xcode 12.');
 

For others waiting for this fix in a new release of the cli, apply the above patch by placing it in a file called @react-native-community+cli-platform-ios+5.0.1-alpha.2.patch in your project folder, and running:

patch -p1 < @react-native-community+cli-platform-ios+5.0.1-alpha.2.patch

I'm getting patch unexpectedly ends in middle of line after running the command. I pasted the diff into the new file with no changes. Anyone know why?

Just delete the line 13 if you copy paste from above and get an empty line (13) at the end.

RogerParis avatar May 31 '21 16:05 RogerParis

5.0.1-alpha.2 not working for me

ghasemikasra39 avatar Jun 01 '21 10:06 ghasemikasra39

not working 5.0.1-alpha.2 i'm building with xcode

oussamabenkortbi avatar Jun 01 '21 21:06 oussamabenkortbi

5.0.1-alpha.2 was published before PR #1407 was merged. I recommend you consider trying the 6.0.0-rc.0 or @react-native-community/cli@next version from npm which should include the bugfix.

Sadly it doesn't fix the issue, because 6.0.0-rc.0 with the current 0.64.1 react-native version is not compatible. So this will be fixed with react-native version 0.65.0 I guess. Patches are the option until then.

f4z3k4s avatar Jun 02 '21 10:06 f4z3k4s

Worked for me but ran into a small newline warning with my linter. Solution is to run echo -e "\n" >> @react-native-community+cli-platform-ios+5.0.1-alpha.2.patch

lundjrl avatar Jun 02 '21 20:06 lundjrl

just update the cli-platform-ios inside @react-native-community/ try this npm i @react-native-community/cli-platform-ios

hope it works

amma-dev avatar Jul 13 '21 14:07 amma-dev

We were able to solve this by upgrading react-native package to latest release: https://reactnative.dev/docs/upgrading

react-native package seems to be using CLI tools from its peer dependencies (which in our case was @react-native-community/[email protected] with [email protected]). Seems like this behavior is counterintuitive, here's a separate issue report for that: https://github.com/facebook/react-native/issues/32002

GrabbenD avatar Aug 11 '21 09:08 GrabbenD

After upgrading to the latest version of Xcode 13.2.1 was hitting "error No iOS devices connected." as well after running react-native run-ios --device. Tried to upgrade my react-native version from 0.62 to 0.64.2 (removed instruments error) and still doesn't work.

In the end it's due to my iPhone (iOS 15.2.1) name is having brackets! (e.g. iPhone (2)). These brackets were added automatically to the iPhone name after migrating from old iphone to new iphone.

So if everything doesn't work for you just remove the brackets from the iPhone name!

Keatooon avatar Feb 18 '22 02:02 Keatooon

I ran into the same issue, and found the same solution as you. Temporarily fixing with the following patch-package patch: @react-native-community+cli-platform-ios+5.0.1-alpha.2.patch

diff --git a/node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js b/node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js
index ac4cd9f..ce330d8 100644
--- a/node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js
+++ b/node_modules/@react-native-community/cli-platform-ios/build/commands/runIOS/index.js
@@ -128,7 +128,7 @@ function runIOS(_, ctx, args) {
   let devices;
 
   try {
-    devices = (0, _parseXctraceIOSDevicesList.default)(_execa().default.sync('xcrun', ['xctrace', 'list', 'devices']).stderr);
+    devices = (0, _parseXctraceIOSDevicesList.default)(_execa().default.sync('xcrun', ['xctrace', 'list', 'devices']).stdout);
   } catch (e) {
     _cliTools().logger.warn('Support for Xcode 11 and older is deprecated. Please upgrade to Xcode 12.');
 

For others waiting for this fix in a new release of the cli, apply the above patch by placing it in a file called @react-native-community+cli-platform-ios+5.0.1-alpha.2.patch in your project folder, and running:

patch -p1 < @react-native-community+cli-platform-ios+5.0.1-alpha.2.patch

I'm getting patch unexpectedly ends in middle of line after running the command. I pasted the diff into the new file with no changes. Anyone know why?

Just delete the line 13 if you copy paste from above and get an empty line (13) at the end.

This patch worked for me, why is this not merged into the NPM package?

pprotas avatar Jun 23 '22 08:06 pprotas