Das wollte ich tun, aber die bestehenden Lösungen fand ich alle nicht so toll.
Well, also noch mal.
Immerhin bietet Python ja eine menge mit seinen Batteries Included. Das heißt ich muss nicht aufwendig mit RegExen die plist dateien auseinander nehmen. Schließlich gibt es die plistlib.
Hier das Resultat:
#!/usr/bin/env python # Usage: # Either copy into a shell script build phase # (don't forget to change the interpreter to "/usr/bin/env python") # Or just put it into a shell script and call it form there. # # Discussion: # There are really two info plist keys that could be used for the source revision: # The CFBundleShortVersionString and CFBundleVersion # Apple recommends to use CFBundleVersion, because it is not shown in the finders info dialog, # but is shown in the standard about dialog of a cocoa application where the CFBundleVersion # is shown in parantheses behind the CFBundleShortVersionString. # # Inspired by Daniel Jalkut at http://www.red-sweater.com/blog/23/automatic-build-sub-versioning-in-xcode # License: Creative-Commons Public Domain http://creativecommons.org/licenses/publicdomain/ import os, re, plistlib # Test if run from xcode is_run_from_xcode = os.environ.has_key("BUILT_PRODUCTS_DIR") if not is_run_from_xcode: exit("Needs to be run from a Xcode shell scribt build phase") # We take the one from the built products dir to keep revision numbers out of the repository info_plist_path = os.path.join(os.environ["BUILT_PRODUCTS_DIR"], \ os.environ["INFOPLIST_PATH"]) # get latest svn revision def output_of_command(*command_and_arguments): import subprocess return subprocess.Popen(command_and_arguments, stdout=subprocess.PIPE).communicate()[0] os.chdir(os.environ["PROJECT_DIR"]) version_range = output_of_command("svnversion", "-nc") latest_commited_version = re.search(r"\d*\w*$", version_range).group(0) # enter into Info.plist info = plistlib.readPlist(info_plist_path) info["CFBundleVersion"] = latest_commited_version plistlib.writePlist(info, info_plist_path)
Pretty neat. :)
Die aktuelle Version des Scripts liegt wie immer [source:open-source/utilities/xcode-add-subversion-version-to-built-Info.plist.py im Repository].