iOS Automate Build Version Number

If you have a continuous integration server, you might want to build your app with unique version numbers tied to the build.

The agvtool (Apple-generic versioning tool for Xcode projects) is an easy way to update the marketing and build version number within your app.

In your CI system, you can run something like the following to add a build version number where the major version is the same but the .jenkins.$BUILD_NUMBER is appended. $BUILD_NUMBER is provided by Jenkins.

MARKETING_VERSION=$(agvtool what-marketing-version -terse1); agvtool new-version -all $MARKETING_VERSION.jenkins.$BUILD_NUMBER