Expokit and localhost

So, I have detached my app to use bluetooth and everthing works on android but it’s a mess on iOS.

First thing: I’m using a VM to run OSX and exp start, the project build well, but when it launch on the device I’ve got:
“Error while loading: Could not connect to the server” code 1004.

Plus, the packager ip looks like <exp random numbers>://localhost:19000

How to change the “localhost” part? The device doesn’t ask for ip or anything, tried to change IP in EXBuildConstants.plist but the value is rewrite everytime I build with Xcode. I can’t change any IP in AppDelegate.m (or I don’t know where to change it)

Btw, I can access my packager data from outside the VM, so the network is well configured.
Thanks

Hi, the exp<random numbers> scheme is deliberate. It’s how XDE/exp know which app to open on your device/simulator (since you aren’t using Expo Client any more).

You can change the type of url to something besides localhost the same way you would prior to detaching, by clicking the gear menu in XDE or using a flag on exp start when serving your project.

Thanks, but it’s seems I have miss explained my problem.
The packager works fine and give me exp<random numbers>://192.168.11.82:19000 , nothing wrong here.

But when I build my app from xcode on my device, I’ve got an error in app : “Error while loading: Could not connect to the server” code 1004.

The built app tries to load exp <random numbers>://localhost:19000 when the packager serve the code on <exp random numbers>://192.168.11.82:19000

@ben @discourse hi all, i have same problem. Error while loading: Could not connect to the server” code 1004.

how to change EXBuildConstants.plist

Hi!

I’m a bit confused by the mention, is something wrong with Discourse?

Josh
~ Discourse Technical Advocate

Not in my case, must be a msitake from @weizeng

1 Like

@ben any idea about our problem?
Thanks!

1 Like

The value in EXBuildConstants.plist is written by the “Prepare ExpoKit” build phase in your detached Xcode project. It runs a script to ping your local packager and asks what url it should load, then writes that url to EXBuildConstants so that the iOS app can hit this at runtime.

Sounds like either something’s causing the build hook to retrieve the wrong url, or something’s up with your local network. What happens if you restart your packager to specifically serve a localhost url instead of a LAN ip?

Seems like exp start --host localhost is working with simulator but I can’t test on device atm. Saldy I’m not sure it will work since the app ping for the localhost url.

Tested in device right now, but the app tries to ping a localhost url.

Have the same problem. Always return localhost instead of the real ip. Any chance to set it manually?

My problem was: I build in xcode before exp start, and since this command overide an ios file it couldn’t work.

Seems like you can’t serve the code from another computer, and you can’t set the ip manually

Seem same problem. I build the detach app with xcode and exp start in the same machine.

Normally, the app build will fill the real ip of the machine in EXBuildConstants.plist, but now it is always override the ip with “localhost”. Result, the app can’t connect to the machine.