42
votes

I'm working on an app right now and we're trying to get some testing done against the staging environment as well as the production environment. Naturally, I've created "Stage" and "Prod" build configurations to switch between the two, but my client would like to have the two installed side by side so they could switch between the two environments easily. I've been doing this so far by maintaining a branch of my code with a different bundle identifier and bundle display name, so they can be installed and tested side by side. I'm beginning to wonder if there may be an easier way to do this, though. Is there a way I could define a custom build setting, give it a value based on the build configuration, and then append that to the end of the bundle identifier?

Something like...

BUNDLE_SUFFIX
    TEST
    STAGE   
    PROD    ".PROD"

...and then set my Bundle Identifier to com.blah.blah$(BUNDLE_SUFFIX). Then all builds with the PROD config will automatically get the new bundle id and I won't have to synchronize branches all the time. Is that kind of thing even possible?

2
One thing you could do is check the bundle ID in code and modify your apps behaviour based upon the bundle id. I have three versions of an app; development version, testing version and live version : each uses different web apis. So I check the bundle identifier at runtime to determine which URLs to use. - ader
I also use different targets with different profiles, bundle identifiers and names, so I don't have to mess with any branching for this. - ader
Is it only url that is changing in your stage and production build ? - Mihir Mehta

2 Answers

50
votes

In Xcode 7:

this can be done easily using the packaging configuration in build setting

enter image description here