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

Created on 29 Apr 2021  路  13Comments  路  Source: react-native-community/cli

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.

bug report

Most helpful comment

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.');


All 13 comments

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 mind sending a PR? :)

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

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 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?

Hello,
Not working for me:

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

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.

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

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.

5.0.1-alpha.2 not working for me

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

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.

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

Was this page helpful?
0 / 5 - 0 ratings