Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

React-Native IOS real device does not connect to Metro server

My Simulator works fine it connects to the development server first try. But on my real device I have to delete node modules, reinstall Podfiles, clean building folder and delete Derived Data then it loads a bunch of time in Xcode and finally connects to dev server. But after I stop it and I want to run it again it wont connect. I used to able to just run npm start and launch my app on my phone and it connected automatically, and I could make changes, it refreshed and everything, but now even with Xcode running it doesn't work 10/9 times.

And yes I'm on the same network with my phone as the computer. I tried to set my mac's IP on Bundle Settings on the phone, no success.

Anyone got any idea?

like image 671
Mark Kiraly Avatar asked Nov 07 '22 01:11

Mark Kiraly


1 Answers

Have the same problems. These are my steps to 'fix' this:

  • Ensure that you don't have ethernet internet cable plugged in. Only wifi network (iPhone and Mac has to be on the same wifi network)! I think that this was the main problem in my situation.
  • Turn off the metro, the app usually starts (because the native app build contains also js build).
  • Then run the metro again.
  • Shake your device and Configure Bundler with your Mac's IP
  • it seams that only resave of this screen helps - so you don't have to spend time with finding and entering the IP
  • Then it should connect to your metro

I spent hours trying all possible fixes...

Another hints:

  • https://github.com/facebook/react-native/issues/29587
  • https://github.com/facebook/react-native/issues/29396
  • delete pods file
  • update ios pod
  • cleanup DerivedData
  • update react-native (I don't have problem with clean RN app)
  • update xCode, iPhone, Mac
  • try different iPhone device
like image 109
Petr Spacek Avatar answered Nov 15 '22 13:11

Petr Spacek