groups

Link to this snippet:


Download to Code Collector

language: Ruby
licence: BSD

Bazaar revno build phase script

options: send to code collectorview all jfro's snippets
#!/usr/bin/ruby
# Simple bazaar version numbering build phase script
#   by Jeremy Knope <jerome@buttered-cat.com>
#   with thanks to Rudy for the ruby plist extension help

# Requirements: osx-plist ruby gem, install via:
#
#  $ gem sources -a http://gems.github.com/ (you only need to do this once)
#  $ gem install kballard-osx-plist
#

# Only run if we're versioned by bazaar
if File.exists? '.bzr'
	require 'rubygems'
	require 'osx/plist'
	ENV['PATH'] += ':/usr/local/bin' # this is more friendly than hardcoding the command below

	revisionNumber = `bzr revno`
	# We set the path to the Info.plist file to the built product's plist instead of source plist
	plistFile = File.join(ENV['BUILT_PRODUCTS_DIR'], ENV['INFOPLIST_PATH'])

	plist = OSX::PropertyList.load(File.open(plistFile))
	plist['CFBundleVersion'] = revisionNumber.strip
	OSX::PropertyList.dump(File.open(plistFile, 'w'), plist, format = :xml1)
end