Unable to run iOS on Device from Command Line - Simulator Works. RCT_METRO_PORT undefined
See original GitHub issue- I have reviewed the documentation
- I have searched existing issues
- I am using the latest React Native version
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:
- Created 5 years ago
- Reactions:22
- Comments:32 (4 by maintainers)
Top 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 >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Just installed 0.55.0 and it’s still happening, can anyone else confirm?
I can confirm that
react-native run-ios --device
does not work on react-nativeversion 0.54.2
As workaround, this works for me:ios-deploy -c
to get the udid of my phone and then usereact-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 withrunOnDeviceByUdid(...)
andrunOnSimulator(...)
.