views:

29

answers:

2

My iPhone app consumes a Java web service in order to get data. At my company we have 3 environments - development, testing, production. Each environment's URL, that points to the web service, is different. Thus, each time we promote the project to the next environment I must change the hard-coded URL in the iPhone code to match that of the targeted environment. Has anyone devised a strategy to handle this either on the iPhone itself or in the service layer?

+1  A: 

Try storing the variable part of the URL in your app's info.plist file. You can change that w/o rebuilding.

If more config changes are needed, VCS branching may be what you need.

fish2000
I second that. I do this all the time.
Matt Williamson
A: 

You might consider the following approach:

  1. When you start up your app, or rather when you have established that a network connection is possible, you send your device id to the server.

  2. The server checks your device id against a list and tells your app whether the user talking to the server is allowed to see development and testing content.

  3. If your device is allowed to, you provide an interface for the user to change whether they want to see development, testing or production content. Store that in NSUserDefaults

  4. Depending on user choice, the corresponding url is used to talk to your server. To be sure, you can include your device id check here, too.

This approach has the benefit that you can allow clients to see testing content... without ever having to update or change their app. And you can revoke that permission anytime.

Joseph Tura