Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React Native iOS simulator "Connect to Metro to Develop Javascript"

I'm running a react native app and constantly running into the issue of the app not connecting to the code to do automatic updates.

Things I've tried:

  • Reloading main.jsbundle via the following command: npx react-native bundle --entry-file index.js --platform ios --dev false --bundle-output ios/main.jsbundle --assets-dest ios/assets
  • Completely removing node and react native from my computer
  • Restarting my computer
  • Running on a physical device and running on the simulator
  • Cleaning derived data in Xcode

This is the screen on starting up, which offers the advice, "Connect to Metro to develop JavaScript."

Connect to Metro to develop JavaScript.

From the metro bundler that automatically starts up, I get this message when I type 'r' to reload that says, "React Native: No apps connected."

"No apps connected"

I'm using 0.61 and always have been.

What else should I try?

EDIT

I was able to get it working by restarting my computer (again).

Every once in a while, a restart does the trick, yet most of the time it doesn't work. There still has to be a more reliable way of fixing this.

like image 577
bearacuda13 Avatar asked Feb 28 '20 20:02

bearacuda13


2 Answers

Dev menu looks like:

enter image description here

In my case it could happen after recreating main.jsbundle

  1. Open any installed ios simulator.
  2. install your app (npm run ios)
  3. press cmd + d being focused on simulator
  4. choose configure bundler

bundler preferences:

enter image description here

  1. bundler address - 127.0.0.1
  2. port - 8081

then simulator will reconnect itself

like image 122
wentris Avatar answered Oct 14 '22 19:10

wentris


I had the same issue some time before. Suddenly the App doesn't work anymore if starting only with XCode. I have to start the metro-bundler via CLI... and if running, I had to use "XCode" to run the App. As the metro-bundler still running in the background, XCode didn't start it's own, and the connection could be established.

I've described my request here... which sounds a bit similar to yours. Now I don't have any issues anymore if starting from xcode directly. Maybe this was caused of an upgrade of XCode (my current XCode-Version: 10.3)

like image 45
suther Avatar answered Oct 14 '22 20:10

suther