Skip to content

Instantly share code, notes, and snippets.

@iloveitaly
Created October 30, 2011 21:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save iloveitaly/1326457 to your computer and use it in GitHub Desktop.
Save iloveitaly/1326457 to your computer and use it in GitHub Desktop.
Automatic Build Numbers for XCode
#!/bin/bash
BASE_VERSION=572
VERSION_NUMBER=$((`git describe --match SVN-Import | ack "([0-9]+)-[^-]+$" --output='$1'` + $BASE_VERSION))
#!/usr/bin/env python
import os
BASE_TAG = "SVN-Import"
BASE_VERSION = 572
# note that BASE_VERSION is for projects that were imported from SVN and want to maintain a constant
# version number history. Not the best solution, but it works (I know it is possible to pull svn
# commits into git, but this project did not)
def increaseVersion():
from AppKit import NSMutableDictionary
# result: SVN-Import-12-gb63066a
version = os.popen('git describe --match ' + BASE_TAG).read()
version = version.split('-')[-2]
# failing to cost the version to string might cause issues with Sparkle
projectPlist = NSMutableDictionary.dictionaryWithContentsOfFile_('Resources/Info.plist')
projectPlist['CFBundleVersion'] = str(int(version) + BASE_VERSION)
projectPlist.writeToFile_atomically_('Resources/Info.plist', True)
if __name__ == '__main__' and os.environ["CONFIGURATION"] != "Debug":
increaseVersion()
#!/usr/bin/python
import os, platform
from AppKit import NSMutableDictionary
def increaseVersion():
# reading svn version
version = os.popen('svnversion -n').read()
version = version.split(':')[-1]
if not version[-1].isdigit():
version = version[:-1]
# reading info.plist file
projectPlist = NSMutableDictionary.dictionaryWithContentsOfFile_('Resources/Info.plist')
# setting the svn version for CFBundleVersion key
projectPlist['CFBundleVersion'] = version
projectPlist.writeToFile_atomically_('Resources/Info.plist', True)
if __name__ == '__main__':
increaseVersion()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment