I'm working on some iPhone apps that communicate with an HTTP-based API server (which happens to be Rails, but that's irrelevant here), and oftentimes I've been bitten by the IP (un)reachability from the iPhone device to my MacBook Pro - the iPhone device must hit the URLs on the MBP.
Right now, I have something like this in Config.h:
#if (TARGET_IPHONE_SIMULATOR)
// for iPhone Simulator
#define API_BASE @"http://127.0.0.1:3000/api"
#else
// for iPhone Device
#define API_BASE @"http://10.0.0.1:3000/api"
#endif
It works fine, as long as: 1. you work by yourself, 2. or you have full control over the DHCP server, 3. or you can work only with the iPhone simulator and use the loopback address (that is, without push notification or in-app purchase).
But I work remotely with other people, often from cafes or libraries, so it bothers me a lot - now I have to manually find my MBP's assigned IP address, rewrite the above constant API_BASE from "10.0.0.1" to the new address, and not forget to revert to the original before committing to git or svn.
Is there any ways to programatically get the IP address of the development machine from inside Xcode and send it to the iPhone device on a per-build basis?
UPDATE
Using Bonjour is not enough because every machine in the team has a different name.