Brian Dunagan

April 13 2010
Xcode Tip: Update Version Numbers with agvtool

Apple includes a handy commmand-line tool called agvtool for updating Xcode project version numbers via Terminal. Run the tool with a build version or marketing version, and it modifies a couple fields:

  • project.pbxproj's CURRENT_PROJECT_VERSION
  • Info.plist's CFBundleVersion ("Bundle version")
  • Info.plist's CFBundleShortVersionString ("Bundle versions string, short"). </ul>
    $ agvtool new-version -all ""
    Setting version of project sample to:
    Also setting CFBundleVersion key (assuming it exists)
    Updating CFBundleVersion in Info.plist(s)...
    Updated CFBundleVersion in "sample.xcodeproj/../sample-Info.plist" to
    $ agvtool new-marketing-version "1.2.3 (4)"
    Setting CFBundleShortVersionString of project sample to: 
        1.2.3 (4).
    Updating CFBundleShortVersionString in Info.plist(s)...
    Updated CFBundleShortVersionString in "sample.xcodeproj/../sample-Info.plist" to 1.2.3 (4)
    Google "agvtool" and you'll inevitably come across two great posts: Apple's Chris Hanson covering the tool's goal and Red Sweater's Daniel Jalkut discussing its automation. They go into much greater detail. Keep two caveats in mind when using agvtool:
    • Key Existence: agvtool only modifies project.pbxproj and Info.plist where it sees specific keys. It doesn't add an entry, and CURRENT_PROJECT_VERSION only appears in the project file after you change the value in Versioning->Current Project Version.
    • Key Replacement: agvtool modifies the values for specific keys in these two files. It doesn't search through the files and replace the keys with the values. So, "${CURRENT_PROJECT_VERSION} Copyright 2010" doesn't become " Copyright 2010". </ul>
Time is money: Quantify wasted meetings with Dollar Clock Marketing Tip: Name Your Downloads
LinkedIn GitHub Email