For example, this iPhone screen snapshot demonstrates dev, beta & release builds of my hobby project River Level installed side-by-side.
Dev, beta & release builds of River Level installed side-by-side |
Note that some iOS features – like Push Notifications, Game Center and In-App Purchase – require the Bundle Identifier to match the value configured in iTunes Connect so you can test these features. In those cases this technique won't be effective, unless you set up multiple app instances in iTunes Connect for each build configuration.
The other parameter I customise per build configuration is the Bundle Display Name (CFBundleDisplayName). This is the app name as displayed on the home screen. iOS doesn't require these names to be unique, so if you changed the Bundle Identifiers without changing the Display Names you would end up with multiple instances of your app all with the same name and icon, making it difficult to work out which build is which.
My convention is to append "∆" to dev builds and "ß" to ad hoc builds.
To customise the Bundle Identifier and Bundle Display Name per build the process is:
- Append ${BUNDLE_ID_SUFFIX} to the "Bundle identifier" in Project-Info.plist.
- Append ${BUNDLE_DISPLAY_NAME_SUFFIX} to the "Bundle display name" in Project-Info.plist.
Custom variables appended to Bundle Display Name and Bundle Identifier values |
Note that with no other changes these variables will be expanded to empty strings and so will have no effect. This is how I handle Release builds, so they are submitted to the App Store with standard values.
The next step is to define the custom values for each build configuration. My convention is:
Development (Debug) builds:
BUNDLE_DISPLAY_NAME_SUFFIX=∆
BUNDLE_ID_SUFFIX=.dev
Ad Hoc builds:
BUNDLE_DISPLAY_NAME_SUFFIX=ß
BUNDLE_ID_SUFFIX=.adhoc
Neither of these settings is defined.
The place to put these settings is in each relevant Build Configuration of the Project. Note: some people edit the build configuration for their Target, but I recommend only doing this if you need a setting specifically for a build target. If you only have one target, edit the build settings for the whole Project. That way, if you add Targets later they will inherit the Project build settings.
To add custom settings to build configurations, in Xcode 3:
- Select menu "Project" / "Edit Project Settings"
- Select "Build" tab
- Select a build configuration in the Configuration list (e.g. "Debug")
- Select "Add User-Defined Setting" from the command list (bottom left corner pulldown)
- Add a user-defined setting for each of "BUNDLE_DISPLAY_NAME_SUFFIX" and "BUNDLE_ID_SUFFIX" with the values you choose.
- Repeat this for each build configuration that you want to install separately to the others.
User-defined settings for a Debug build configuration |
To see any user-defined settings, scroll the build settings table to the bottom; or use the "Show" list to filter only "User-Defined Settings" (Xcode 3).
To delete a user-defined setting, highlight the setting and hit the delete key.
That's it. Now re-build and install and the app should appear separately to the other builds. Feel free to install as many different builds as you feel like.
This works very well. However, do you have any issues debugging from Xcode on the device? When I build for Device/Debug the production version of the app launches, not the ∆ version. It seems like Xcode is sending some wrong info, but I can't seem to find the setting
ReplyDelete@dmorrow: I don't remember ever seeing that problem where the wrong build is debugged. If you work out what was wrong let me know in case anyone else hits the problem.
ReplyDelete1. There is a problem when you need a title translation. It just doesn't work because overwritten by InfoPlist.strings values.
ReplyDelete2. And a nice tip: if you don't need to change "Bundle identifier" you can set different Product Names in project settings. :)
Year I ran into the push-notification certificate issue :(
ReplyDeleteI'm going to try to create 3 different appids... stupid Apple.
Great article! Thank you
ReplyDelete@Chris Miles Thanks for sharing this info.
ReplyDeleteCurrently I am using Xcode 4.6 and I added Debug and Release setting but where should i set Ad-Hoc setting?
FYI:
In XCode-5 this has changed.
http://stackoverflow.com/questions/10854156/how-to-create-variables-for-use-in-xcode-build-settings-values