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.

Unable to run iOS on Device from Command Line - Simulator Works. RCT_METRO_PORT undefined

See original GitHub issue

I am unable to run my app on my iOS device via the command react-native run-ios --device. I am able to run it on the simulator via react-native run-ios and I am able to open the XCode project and run on my device directly from the project. When compiling, I receive the following error:

/Users/justin/VSCodeProjects/MyApp/node_modules/react-native/React/Base/RCTBundleURLProvider.m:17:53: error: use of undeclared identifier 'undefined'; did you mean 'underline'?
const NSUInteger kRCTBundleURLProviderDefaultPort = RCT_METRO_PORT;
                                                    ^~~~~~~~~~~~~~
                                                    underline
In file included from <built-in>:359:
<command line>:5:24: note: expanded from here
#define RCT_METRO_PORT undefined

Just from that message, it appears that RCT_METRO_PORT is undefined and causing the build to fail while using the command line to run the app on iOS on my device.

I have googled this error and nothing has come up to this point. Any ideas?

Environment

Environment:
  OS: macOS High Sierra 10.13.3
  Node: 8.9.3
  Yarn: Not Found
  npm: 5.7.1
  Watchman: 4.9.0
  Xcode: Xcode 9.2 Build version 9C40b
  Android Studio: 3.0 AI-171.4443003

Packages: (wanted => installed)
  react: 16.3.0-alpha.1 => 16.3.0-alpha.1
  react-native: 0.54.2 => 0.54.2

Steps to Reproduce

You can clone my repository and try out the command react-native run-ios --device.

Expected Behavior

I expected that it would run on my device.

Actual Behavior

Build fails with an error described above.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:22
  • Comments:32 (4 by maintainers)

github_iconTop GitHub Comments

25reactions
jaygouldcommented, Apr 3, 2018

Just installed 0.55.0 and it’s still happening, can anyone else confirm?

13reactions
b45ch1commented, Mar 24, 2018

I can confirm that react-native run-ios --device does not work on react-native version 0.54.2 As workaround, this works for me: ios-deploy -c to get the udid of my phone and then use react-native run-ios --udid e0452************************************ to compile and deploy the project to the phone.

To fix the issue, I believe one has to adapt the function runOnDevice(…) in file node_modules/react-native/local-cli/runIOS/runIOS.js and make it consistent with runOnDeviceByUdid(...) and runOnSimulator(...).

Read more comments on GitHub >

github_iconTop Results From Across the Web

"Unable to boot device" error mess… | Apple Developer Forums
Unable to boot device because it cannot be located on disk. The simulator comes up, but (usually) the app doesn't run (occasionally, it...
Read more >
Run react-native application on iOS device directly from ...
brew install ios-deploy; npx react-native run-ios --device. The second command will run the app on the first connected device.
Read more >
VS for Mac 2022 Preview 7 can't launch iOS app in debug mode
Launching the app manually by clicking on it in the simulator works fine (the app launches and executes correctly). Next diagnosing step: Execute...
Read more >
iOS Simulator from the Command Line | RY 's Blog
Launch command is used to launch a application in your simulator device. 1, xcrun simctl launch booted com.apple ...
Read more >
Running On Simulator - React Native
Specifying an UDID​. You can specify the device UDID returned from xcrun simctl list devices command. E.g. run npx react-native run-ios --udid ...
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