Jenkins iOS Build - Inject Jenkins build number into app's main plist file Jenkins iOS Build - Inject Jenkins build number into app's main plist file jenkins jenkins

Jenkins iOS Build - Inject Jenkins build number into app's main plist file


You can use agvtool to auto increment the build number. This command line tool is part of the Xcode tools, so you should already have it installed.

There are a few preparations you need to do in your project to make agvtool work:

  1. Open your project in Xcode and click on the project
  2. Select the target you want to set the build version for
  3. Go to Build Settings and make sure you have "All" selected
  4. Scroll down to Versioning and select Apple Generic as the versioning system
  5. Set the current project version to 1, also set your build number in the project overview (general tab) to the same build number

Now you should be able to open a command line in your project folder and type

agvtool what-version

This will output the current version of your project (1). Next go to your Jenkins and add a Shell Script build step. This should happen before the project is built!

In this build step you can increment the build number:

agvtool next-version -all

or set a specific version:

agvtool new-version -all 10

Above will set the version to 10. You can also use Jenkins environment variables here instead of 10, like ${BUILD_NUMBER} for example.

The -all switch is used to also update the CFBundleVersion of your project.