React Native on Ipad - Error - could not connect to development server - ios

I'm using React-Native, when I run the AwesomeProject with Xcode and iPhone simulator everything works well, but when I connected my iPad and built the project on my iPad I receive an error on the iPad when the app starts:
"Could not connect to development server. Ensure node server is
running. The operation couldn't be completed (NSURLErrorDomain error
-1004)".
I also ensured that the node package is running. I even restarted Xcode and started it all over with running npm start.
Could you please assist?

On your AppDelegate.m you have to update the jsCodeLocation and replace localhost with your machine ip address.
Either that or bundle the compiled source into your application, which is commented as option 2 on AppDelegate.m as well. You download the compiled code, and add it to your Xcode project.

Try to take a look here for the solution:
https://github.com/facebook/react-native/issues/240#issuecomment-86977126

Another potential issue which can cause the exact same error is App Transport Security (ATS) in iOS9--this happened to me, even though everything else was set up correctly. See my description and solution at https://stackoverflow.com/a/34880394/2397068.

I have prepared a small instruction which will help to solve this problem.
When your application cannot connect to the server, you will see the message like this:
Open a file AppDelegate.m in your Xcode project and look for
jsCodeLocation = [NSURL URLWithString:#"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];
You have to replace this address with your local address.
To look up your local IP address in Mac OS X open Terminal application (located in /Applications/Utilities) and type ipconfig getifaddr en1 for wireless, or ipconfig getifaddr en0 for ethernet.
You can check It in browser. And you will see React Native Debugger page
Just replace localhost in AppDelegate.m with your IP address. localhost to 192.168.1.100 in my case.
Run your application in Xcode again.

In my case, I just had a very old version of node.js installed (version 0.8.6). After updating node.js to version 0.12.2, the default project that react-native init AwesomeProject created worked perfectly.

Related

React-native iOS: Could not connect to development server

After restarting Wi-Fi router my local ip has changed from "192.168.1.4" to "192.168.1.3" so I've changed it in AppDelegate.m to
"http://192.168.1.3:8081/index.bundle?platform=ios&dev=true&minify=false"
But I still get error on real device:
Could not connect to development server ...
URL http://192.168.1.3:8081/index.bundle?platform=ios&dev=true&minify=false
When I shake my phone and configure bundler to the same IP 192.168.1.3 and port 8081 app loads successfully. But Fast Refresh is not working and I need to build app and configure bundler every time I make changes in my code.
I also checked "http://192.168.1.3:8081/index.bundle?platform=ios&dev=true&minify=false" in my browser and on another computer in my local network and it works fine. Tried to load the same link on mobile browser with no success.
All devices are using the same network.
I have already tried:
cleaned tmp folders and watchman
cleaned iOS build folder
removed and reinstalled node_modules and pods
killed node process and restarted npm with --reset-cache
restarted xcode, iphone and computer (many times)
reinstalled watchman
set "Connect via Network" in Xcode Devices window
That was issue with expo-splash-screen package which doesn't work on new iOS version. The fact that app was not able to run after wifi restart was just a coincidence. I have seen some non-permanent warnings about splashscreen in Xcode logs but didn't take it seriously.
Removed 'expo-splash-screen' package and everything works fine.
It helped me a lot: https://github.com/facebook/react-native/issues/31369

Could not connect to development server - React Native

I am creating an app using react native. I tried to change a file path to an image within my code and when I ran my app on the iOS emulator the following message was displayed.
I have tried a number of different methods such as closing the terminal and running the app again.
I also tried running localhost:8081 in my browser and was given the following message
I have also tried deleting my node_modules folder and running yarn but this still hasn't fixed the problem.
Any ideas as to how I would fix this?
You can try to clean xcode, remove app in the simulator
cd ios
xcodebuild clean
run bundler
react-native start --reset-cache
Replace the actual IP Address with the "localhost" in the Url and that should fix the issue if the url is proper.
Fully delete the app on the iOS Simulator, then rebuild the app from xcode.

There was problem loading requested app.it looks like you may be using LAN URL

I am not able to compile my project through expo.I have followed all steps to eject expo for run the app in iOS.Please find below error screen shot for your reference.enter link description here
Try expo-cli start --tunnel Working for me.
[16:13:53] Expo DevTools is running at http://localhost:19002
[16:14:10] Your native app is running at exp://fa-2jw.testdev.testdev-expo.exp.direct:80
If the new project build doesn't solve it,
Your uri will look like this.
Your URL is: exp://192.168.43.61:19000
as opposed to this.
exp://9h-hcy.bacon.tickle_me_elmo.exp.direct:80
Then you can try this.
exp start --tunnel and check to make sure you have a pretty solid wifi connection
If not exp start -m tunnel
A detailed description of the connection.
I've had the same problem and no answer here helped me. In fact, I've had a older version of Expo on my iPhone. So, I've update to the latest expo version in my iPhone and then it worked perfectly.
I updated both Node.js on the computer and Expo App on mobile to the latest version. then it worked for me.
Had the same issue.
I am using PC, compile my project through expo and testing on Iphone. This worked for me.
yarn ios
When i used yarn start, I got the same error message as you.
After spending a couple of hours and trying various the below trick worked for me My node version was updated to 13.0. I downgraded by following below commands
$ npm install -g n
$ n 12.14.1
and reinstalled expo cli again
expo version is 3.24.2. (you can check version by expo -- version)
created new project by command expo init (projectName)
npm start
once metro bundler
toggle LAN to toggle and then set back to LAN
as shown in picture
Make sure you switch from the LAN toggle to the Tunnel toggle in youre browser Localhost after running expo start in terminal. also make sure your internet is stable.
I had the same issue. The problem was that my computer was connected to another Wifi than my iPhone.
So to make this work, both devices have to be in the same network.
I hope that helps.
besides what others have written, also certain node versions could make this error happen. I solved it by switch node the version from 18.6.0 to 18.14.0
I was having a similar issue, my expo app wasn't running on my devices. expo start --tunnel was the fix. Make sure you have a good internet connection.

iOS React Native - The operation couldn’t be completed. No such file or directory

Since yesterday I cannot test my React-Native Apps anymore (not on simulator nor on device). I did uninstall Xcode and re-install. I am testing now with a init AwesomeProject file. Xcode reports "Build Successful" and starts displaying the Launch Screen but then I receive the following message
"[error][tid:main] The operation couldn’t be completed. No such file or directory"
and the Simulator includes message
"RCTFatal" and "RCTBatchedBridge stopLoadingWithError"
etc
and looks like this:
Screenshot of ErrorMessage
Important: I was able to build a clean iOS only Test App whose Build did run successfully.
I also experienced this issue and I think it is the same as is discussed on https://github.com/facebook/react-native/issues/3174, where the problem concerns IPv4/IPv6.
What worked for me: I put an IPv6 address in AppDelegate.m. This worked for the simulator (iOS 8.4/9.0/9.1) and device (iPhone, iOS 9.1):
you get your IPv6 address with: ifconfig | grep inet6 | grep -v fe80::
in AppDelegate.m surround it with brackets, so that:
jsCodeLocation = [NSURL URLWithString:#"http://[abab:1234:1234:abab:aaaa:bbbb:1111:2222]:8081/index.ios.bundle?platform=ios&dev=true"];
A more detailed story, concerning IPv4/6 addresses in AppDelegate.m:
in simulator:
iOS 9.0 and 9.1:
IPv4 doesn't work, however a hostname such as localhost does
IPv6 works
iOS 8.4:
IPv4 and IPv6 work
on device, iPhone with iOS 9.1:
IPv4 actually does work for me
IPv6 also works
In your AppDelegate.m file, check the following line
jsCodeLocation = [NSURL URLWithString:#"http://localhost:8081/index.ios.bundle?platform=ios&dev=true"];
If the path is not set to localhost, the emulator won't work. If you want to run the app in your phone, have your IP address instead of localhost.

Blackberry Simulator Network issue on Windows7/64bit/32bit(on vmfusion), what to do?

i have Windows 7 64bit on my PC and i have Windows 7 32bit on my vmfusion on mac.
The problem is as follows, if i run early version of blackberry simulators (not touchscreen, but with scroll ball), i do not get network access. I try to run MDS as i have read on forums, but it looks like MDS quits, and i still have no network acess.
The new simulators, let me just run them, and i dont even need to lunch mds, i get access to network with no problem. But the project i am working on, requires me to test mobile site again older blackberry devices.
So here is what i have done so far:
Made sure i have following for java: "C:\Program Files (x86)\Java\jre6" "C:\Program Files (x86)\Java\jdk1.5.0_22" "C:\Program Files (x86)\Java\jre1.5.0_22", do i need anything else?
set up environment path variable to bin folders: C:\Program Files (x86)\Java\jdk1.5.0_22\bin;C:\Program Files (x86)\Java\jre1.5.0_22\bin;
installed everything at separate location as administrator (D:\Programs\Research In Motion), so not to have any write/read issues.
installed MDS and then BlackBerry Smartphone Simulators 4.5.0 - 4.5.0.81 (8100)
now i try to run MDS first, and i see two cmd/three windows popping up one after another, and closing right away. I start up simulator and everything starst great, but when i go to browser and try to navigate to web resource i get an error "Unable to connect to the selected Mobile Data Service, please try again later".
Little edit:
I have moved my effort to XP, which solved MDS start up issue, but simulator still cant establish network connection. See screen shot.
To start MDS you will have to start a console with "Run as administrator" then go to the path where you installed mds and start the .bat file from your elevated console.
Here the console command to start MDS.
EDIT
When MDS is running you can connect to it with your browser to see what is not working
goto : http://localhost:8080/

Resources