Using agvtool to Update Version and Build Numbers

February 5th, 2018

Filed under: Xcode | Be the first to comment!

Apple bundles a command-line tool with Xcode, agvtool, to automatically update your project’s version and build numbers. This article shows you how to use agvtool in your Xcode projects.

Enabling agvtool in Your Project

Before you can use agvtool, you must tell Xcode to use it for your project. To enable agvtool, change the following build settings:

  • Set the Versioning System build setting to Apple Generic.
  • Give the Current Project Version build setting an initial value. Agvtool works best with integer build numbers. 1 is a good choice.


Updating the Build Number

Because agvtool is a command-line tool, you have to run it from the Terminal application. Navigate to your project’s directory before running agvtool.

The most common thing you will be doing in agvtool is incrementing the build number. Run agvtool with the next-version -all option to increment the build number.

agvtool next-version -all

To set the build number to a specific value, supply the desired build number. The most common reason for explicitly setting a build number is to use non-integer build numbers. The following example sets the build number to 8.2:

agvtool next-version -all 8.2

The what-version option lets you see the current build number.

agvtool what-version

Updating the Version Number

To update the version number of your project, run agvtool with the new-marketing-version option and supply the version number. The following example sets the version to 0.5:

agvtool new-marketing-version 0.5

The what-marketing-version option lets you see the current version number.

agvtool what-marketing-version

Leave a Reply

Your email address will not be published. Required fields are marked *