App in react native (ios) only starts when phone connected to mac - ios

I'm starting to develop a react-native app, so almost not experience at all. So far I have my app installed in an iPhone. When I start it connected to the mac (by usb) it starts fine and all (it appears a kind of a logging message in green at the top of the screen).
However, when the phone is disconnected from the mac, the app doesn't start well, it gets freezed on the 'Powered by react' screen. I wonder if this is a common problem I cant get rid of quickly.

Because the app on your Phone is loading the JS Bundle from your Mac.
You can run the app standalone on your phone just if it's build release ( the js bundle is embeded) or you change the setting on your phone to instead of loading JS Bundle from localhost, load it from your Mac's IP. you need to be connected to same Wifi.

Related

ExpoCLI- IOS Could Not Connect to Server

I have been working on a react native project in Windows 10 for a while now using Expo to scan the given QR code and test the app on my IOS device. The other day I ran $expo start and everything seemed to go fine until I tried to load the app on my IOS device. I received this message:
Could not connect to server
I then "Run in Web Browser" which worked fine, so I tried accessing 127.0.0.1:19000 in my Iphone's browser (firefox) and it as well could not connect to server. My phone is connected via wifi which is 2.4 or 5g. I wasn't sure how this would effect this so I used a wifi adapter on PC to match which wifi connection phone and PC were on and that didn't help.
I am using react version 17.0.1, expo version 3.28.5, and "react-native": "https://github.com/expo/react-native/archive/sdk-38.0.0.tar.gz"
I have tried:
Turning off windows firewall
Using different Iphones to connect
npm install --global expo-cli
Changing Connection from "LAN" to "Local"
Reinstalling Node
Creating a System Variable called: "REACT_NATIVE_PACKAGER_HOSTNAME" with the value "192.168.2.108". This did change the LAN IP address as intended but it did not resolve the problem. I just got the same message with the new IP address.
This problem just started happening out of the blue and I'm not really sure what to do next. If you need any additional information I'd be happy to give it.
try to use
expo start --tunnel
When you get the message:
"Error loading DevTools ValidationError: "urlType" must be one of [exp, http, redirect, no-protocol]"
Just wait for a bit and the QR code for tunnel will appear. It does the same for me as well.

Can't connect to the development server iOS

I wasted a day and a half and still can't figure out what is going on and can't find any working solutions. I can't debug my react native application on a real device. It worked yesterday in the morning. Now it is not working. As for me, I didn't change anything. XCode always loads a pre-bundled file. I am on the same working wifi. There are no issues with emulators, only real device.
When I am creating a personal hotspot on my iPhone and connect through it - it works! But I don't want to use a personal hotspot, I want to use wifi.
What I tried:
1. Reload laptop
2. Reload Mobile
3. Change the IP address to the local inside of AppDelegate.m
4. Clean build
5. Remove and install node_modules
6. Kill -9 everything that runs on port 8081
7. Enable App Transport Security (Xcode)
8. Connect-disconnect the device
Go to Settings>Network>Advanced....>DNS
Add these two entries
8.8.8.8
8.8.4.4
If the entries field is disabled and you're not able to edit it, click on the 'Lock' icon in the bottom area of that window and enter the password to be able to make changes
Possible Duplicate:
Android Studio - Android Emulator Wifi Connected with No Internet

Building to a device in Xcode.. is there an expiry?

I ask because I installed to a device (by selecting the device from the simulator menu) and everything was working as expected.
However, after a few weeks it stopped working (immediate crash upon opening).
I tried connecting to the internet and running it again.. and that seemed to make it start working again. However the app itself doesn't use any internet connectivity.
Is there some type of expiry Apple sets when installing to a device using this method?
Or could it be related to the Unity framework needing to touch base?

Testing React Native via iPhone IOS

This may be a bit of a silly question but i haven't found a solid answer.
I have created a React Native app which includes making http requests to an external server (https://example.com).
When i plug my iPhone in, connect to wifi and deploy to device it works great. (All certificate signing etc is fine).
Should this app still work on my phone once I have disconnected it from my macbook and/or disconnected it from the same wifi.
It worked initially but then eventually kept crashing on load.
As soon as i plugged it back in and tested it works. Is there a way to keep this app on my device permanently?
No, it won't work. While you're testing it, the application on your phone is loading your React Native JS code bundle from a server running on your computer, normally on http://localhost:8081.
Once the phone loses access to that server, the app on the phone will lose access to that JS bundle and it will crash.
You have to install the app on your phone by creating an IPA (which requires an Apple Developer account), so that the app can be used anytime.

Unable to access server on physical iOS device

I recently set up a provisioning account for my iOS device for my Xamarin project.
The app launches fine and shows to first screen well, but when I attempt to perform an action like Logging in which requires hitting a local database I have in the office, I get nothing on the console output on my server I am hitting (I'm never reaching the server from my app). My code works fine (hits the server and provides output) when running on the iOS simulator, the Android simulator and a physical android device.
I believe this is probably a simple setting, or something of the like (some type of permission for iOS devices?) but I'm not sure where exactly my problem lies.
I'm an idiot. My device was not connected to my office's WIFI so I was unable to hit the server. Leaving this posted incase anyone makes the same mistake as me in the future!

Resources