bdunagan

fill the void - bdunagan

13 Apr 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 "1.2.3.4"
    Setting version of project sample to: 
        1.2.3.4.
    Also setting CFBundleVersion key (assuming it exists)
    Updating CFBundleVersion in Info.plist(s)...
    Updated CFBundleVersion in "sample.xcodeproj/../sample-Info.plist" to 1.2.3.4
    
    $ 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 "1.2.3.4 Copyright 2010". </ul>
Previous LinkedIn Twitter GitHub Email Next