Herbie999
Herbie999

Reputation: 315

How do I get my iphone to connect to local Xampp server on my mac while testing an xcode app

I am doing a Ray Wenderlich tutorial how to make an app like "Instagram". It's my first time setting up a database. I am using Xampp and hosting on my mac.

I CAN get the app to run with the xcode simulator and I can log in and it works with the server. However when I run my iphone device it runs the app but when I go to login through the app it says "Could not connect to server".

What am I missing? I think all my permissions are set to anybody etc... But again I'm totally new to using a database. It seems though that if the simulator can do it the phone should be able to. Also it's not a provisioning problem, that profile is valid and it wouldn't run on my app if it wasn't. I just cant get to the database from the device.

Any help would be awesome!

Upvotes: 1

Views: 5317

Answers (1)

Aloha Silver
Aloha Silver

Reputation: 1394

If the app isn't able to connect to the server, there might be an issue with the server address.

When running on the simulator, you're still on your mac, so something like http://localhost/DATABASE_ALIAS is enough. But when running on a different device, that is no longer true.

To keep things simple, you should make sure the iPhone is connected to same network as your Mac and then replace localhost with either the Mac local IP or its Bonjour address, for instance: http://YOUR_MAC_NAME.local/DATABASE_ALIAS.

To find out the Bonjour address, open System Settings and find the machine name under Sharing. As an example, if it is called "Herbie MacBook", the address would be "Herbie-MacBook.local".

Upvotes: 3

Related Questions