App Center | HockeyApp will be transitioning into App Center on Nov. 16, 2019.

How to do versioning for beta versions on iOS or MAC OS X

The recommended way to do versioning of your beta versions is as follows:

  • Each beta version gets an ongoing build number which increases by 1 for every version as CFBundleVersion in Info.plist
  • Additionally CFBundleShortVersionString in Info.plist will contain you target public version number as a string like 1.0.0

This ensures that each beta version is uniquely identifiable, and that live and beta version numbers never ever collide.

This is how to set it up with Xcode 4 and Xcode 5:

  1. Pick File | New, choose Other and Configuration Settings File, this gets you a new .xcconfig file.
  2. Name it buildnumber.xcconfig
  3. Add one line with this content: BUILD_NUMBER = 1
  4. Then click on the project on the upper left in the file browser (the same place where you get to build settings), click on the project again in the second-to-left panel, and click on the Info tab at the top of the inner panel.
  5. Xcode 4: You can choose "Based on Configuration File" for each of your targets for each of your configurations (debug, release, etc.)

    Xcode 5: Under the Configurations section you can choose an .xcconfig file for each build configuration (debug, release, etc.) and target.

    If you already use a build configuration in there, you can add that to your existing your.xcconfig instead by adding a line like #include "buildnumber.xcconfig". Or create another xcconfig file which includes your existing one and the buildnumber.xcconfig and select that in the UI.

  6. Select your target

  7. Xcode 4: Select the Summary tab

    Xcode 5: Open the Identity section in the General tab

  8. For Build enter the value: ${BUILD_NUMBER}

  9. Select the Build Phases tab

  10. Xcode 4: Select Add Build Phase and choose Add Run Script

    Xcode 5: Open the Editor menu, select Add Build Phase and select New Run Script Build Phase

    Xcode 5.1: Click the + button and select New Run Script Build Phase

  11. Add the following content:

    if [ "$CONFIGURATION" == "AdHoc_Distribution" ]
         then /usr/bin/perl -pe 's/(BUILD_NUMBER = )(\d+)/$1.($2+1)/eg' -i buildnumber.xcconfig
  12. Change AdHoc_Distribution to the actual name of the Xcode configuration you are using for beta builds

If the added script phase is at the last one, the build number will increase after (!!) the build is done, so it is prepared for the upcoming builds. Don't forget to check-in the changes of buildnumber.xcconfig into your SCM.