How do I connect to a server on a dev machine? - ios

I have a REST API on my dev machine. If an app is running on a real device, how do I connect?
At present, I am looking up the IP address of the machine on the local network and setting that as the domain in the app's Info.plist.
However, this is a nightmare because the IP address changes everywhere I go and sometimes it inexplicably won't connect.
Is there an easier way of doing this?

I've used OHHTTPStubs to deal fake data. At least now I can work on the UI without needing to be concerned with the network.

Related

iPhone VPN to track usage

Hi StackOverflow community.
I am beginning a new project and was wondering if I could get some insight on VPNs and iPhones.
I want to create a VPN so that I can route all of my network traffic through it from my iPhone. I also hope to log each request that was routed through the VPN? (Similar to Hooked)
I am not sure where to start - any insight would be helpful!
Here is my initial plan:
1) Create a VPN (what should I use to create it?)
-How to accept iPhone request?
-How to route all requests to where they need to go?
2) Hook VPN up to iPhone and route all traffic through it
This is actually not a programming, but a network question. So you might rather post a question over at serverfault.
You need a VPN server that in best case, has a fixed IP. From your iPhone you connect to this VPN via the external IP. If you don't have a fixed one, you'd need to update the IP from time to time or use DynDNS or something similar, but they're not perfect, as far as I know.
You configure & connect the VPN within the iPhones Settings app (General → VPN)
Within the VPN your iPhone gets assigned an IP address within the IP range of your private network (e.g. 10.0.0.xxx).
All the devices traffic gets routed through the VPN. When you have extensive logging on the VPN sever, you should be able to get a log of these requests.
EDIT
This is all really broad and generalized. But as mentioned, this is mostly about VPN Sever configuration and, thus cannot be further discussed here on SO.

Accessing remotely my web service

I have implemented a web service on my mac and I am able to access its functionalities through the url "http://localhost:8080/ServiceApp-war/resources/".
As I got satisfying results that I could see in the iPhone simulator in Xcode, I decided to connect my iPhone and test on it. But for this to work I think I need to change the "localhost" in my URL to the IP address of my mac.
I tried to replace it with my public IP address and I got a "could not connect to the server" error on my console. I also tried to replace "localhost" with the IP address I found in System Preferences-->Network-->Wi-Fi and I could see that it was working on the simulator but still nothing when I connect my iPhone and run the application on it.
Please provide a solution for accessing my web service remotely.
Thank you.
Create hotspot from your mac, connect to it with your iPhone and try again.
<lame solution>
Try some service for temporary domain, it will make your computer accessible from anywhere.
How do you "connect" your iPhone? USB connection does not create a network. Well, it does create if you turn on Personal Hotspot on your iPhone (maybe in some other cases, dunno). But the most simple way is to connect Mac and iPhone to the same WiFi network.
Once connected, you can use any of "ping" apps available on App Store. Just look for "ping" (some kind of "network reachability test" or so). You can check if your Mac is really reachable on the network.
If it's not reachable, check your network settings on both devices: do they belong to the same subnet, do they use the same gateway, etc.
If your Mac is reachable with ping, then you should deal with your web service. I setup the web server (which is already distributed within OS X): it already has all the settings to allow other devices to connect. But your web service may require some additional setup. It's two basic things: it should bind to your IP address (please check http://YOUR.IP:8080/ServiceApp-war/resources/ from your Mac!) and second, accept incoming connections from other agents, you should find it somewhere in its settings.
Ngrok was the perfect solution I was looking for.
https://ngrok.com
You could also try finch, which is similar to ngrok. It has a nice friendly GUI. https://meetfinch.com

Filemaker go connection to FM database

Is it possible to connect FM go on my iPhone to the FM pro database on the server when the iPhone is not on the same network?
The server has a firewall and remote access is actually only possible though a VPN tunnel.
If not, what opportunities do I have to have a remote acces to the database without copying the file onto the smartphone, and to update the db as soon the iPhone is back in the same WLAN? Due to a slow VPN, installing the VPN on the smartphone is an undesirable option.
Thank you.
You can ask to open a specific port in the firewall (5003) and redirect to the FileMaker Server.
You can also try to remote on one of the local computers from the phone if it is allowed by firewall, but I think you will find using it a bit awkward.
The best option is to use VPN (which you don't want to), so may be it is worth investigating why it is slow. Is it generally slow or it is slow with FIleMaker only? You might have to optimise your system.

Accessing the Local server from iOS over Wifi

My development environment is:
I have a Server application running on the windows and modified host.dat file to map to IP address with server url something like that
192.168.1.220 server.dev.com
192.168.1.221 server-rc.dev.com
to access these servers from Mac application I had to modify mac host file and it seems to be running fine till now.
Now I need to access the local server from iPhone, all the machines are in same wifi, is there any way to access the server application which is running over the window in my private network,
Googling the same problem, it says I need to setup the DNS name in the router, but I am not getting how to do the same.
Update:
From the iPhone simulator I am able to access server, problem coming only form the device.
Thanks for looking at it,
Making use of Fiddler, I could resolve this issue.
Detailed example here

Rails app accessible from LAN machine using IP address, but not Bonjour name?

I'm developing a web-based application for iOS devices and want to access it from my Home Screen (via an icon).
I'm able to see the site from an external device by going to http://10.0.1.4:3000, however when I try http://computername.local:3000, Safari fails to load the page.
I've tried visiting both addresses (without the port) where I have another web server running (on port 80 of course) and these both work perfectly fine.
As you've probably already guessed my application is in Rails and I've tried using both Webrick and 'thin' servers to see if it was the server that was at fault, but still not fixed.
Obviously I'd prefer to use the bonjour name, so that I can always access the app from any LAN, regardless of their IP ranges and other settings.
Any suggestions on ways to resolve this would be greatly appreciated.
Are you advertising a _http._tcp service on port 3000? Check out the mdns command line utility or Network Beacon.
Problem solved.
I'm using Snow Leopard and disabling IPv6 was all that was required for it to work it would seem.
Also of note, publishing the service was not required, mainly because it didn't need to be discovered.

Resources