Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
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