question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

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

See original GitHub issue

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.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:16
  • Comments:17 (2 by maintainers)

github_iconTop GitHub Comments

28reactions
dburdancommented, Apr 29, 2021

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

10reactions
fredeflcommented, May 6, 2021

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
Read more comments on GitHub >

github_iconTop Results From Across the Web

React Native run-ios --device not working after upgrading ...
The question is pretty self explanatory: I just updated the XCode Command Line Tools and now the npx react-native run-ios --device is giving ......
Read more >
"react-native run-ios --device" fa… | Apple Developer Forums
The react-native run-ios --device command fails with an error. The app runs on the simulator using the react-native run-ios command without any problem....
Read more >
Troubleshooting - React Native
Open ~/Library/Developer/Xcode/DerivedData . and look for a folder named after your Xcode workspace (“RNTesterPods-AAAA” where “AAAA” is a ...
Read more >
Using the macOS execution environment - CircleCI
jobs: build: macos: xcode: 13.4.1 steps: # Commands will execute in macOS container # with Xcode 12.5.1 installed - run: xcodebuild -version ...
Read more >
React Native on Apple M1 Silicon without Rosetta-2 - Adapptor
This is unnecessary (even if running Xcode under Rosetta) and if you ... Do the following before installing CLI Tools, because Xcode (in ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found