Nee
Nee

Reputation: 71

How to run local host on Iphone using swift ?

I have a local ruby on rails server set up on -

http://localhost:3000/

I have added allow arbitrary loads in the info.plist

When I run the app on the simulator it works fine, but when I try to run it on the iPhone it doesn't. The app just crashes.

Looking at similar questions I found that I need to use the actual IP. I also turned the Internet sharing on from the preferences.

So I found out my local IP address which is - 192.168.0.8

So in Safari I am testing it out like this http://192.168.0.8:3000/

But it doesn't work!

How can I get this up and running?

Upvotes: 2

Views: 560

Answers (2)

Sebastián Palma
Sebastián Palma

Reputation: 33470

It'd be easier if you Ngrok.

Just start your server, as usually and by default with port 3000, and then run ngrok as to start listening on such port:

./ngrok http 3000

This will give you a public IP which will be accessible for your devices.

Upvotes: 1

Andy Gaskell
Andy Gaskell

Reputation: 31761

Start your rails server like this:

rails server -b 0.0.0.0

Note that if you have a firewall on your computer you may need to open your firewall or run on another port, like port 80.

rails server -b 0.0.0.0 -p 80

Upvotes: 4

Related Questions