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>
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>