Created
September 11, 2014 15:15
-
-
Save mwhuss/4bc8a5a3113b78fd15a7 to your computer and use it in GitHub Desktop.
Set app build number
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#encoding: UTF-8 | |
#!/usr/bin/ruby | |
# xcode-git-cfbundleversion.rb | |
# Update CFBundleVersion in Info.plist file with short Git revision string | |
# | |
# This is based on | |
# http://github.com/guicocoa/xcode-git-cfbundleversion/ | |
# http://github.com/digdog/xcode-git-cfbundleversion/ | |
# http://github.com/jsallis/xcode-git-versioner | |
# http://github.com/juretta/iphone-project-tools/tree/v1.0.3 | |
raise "Must be run from Xcode" unless ENV['XCODE_VERSION_ACTUAL'] | |
GIT = "/usr/bin/git" | |
PRODUCT_PLIST = File.join(ENV['BUILT_PRODUCTS_DIR'], ENV['INFOPLIST_PATH']) | |
REVISION = `#{GIT} log --pretty=format:'' | wc -l`.strip.to_s | |
BUNDLE_VERSION = "CFBundleVersion" | |
if File.file?(PRODUCT_PLIST) and REVISION | |
# update product plist | |
`/usr/bin/plutil -convert xml1 \"#{PRODUCT_PLIST}\"` | |
`/usr/bin/plutil -replace \"#{BUNDLE_VERSION}\" -string \"#{REVISION}" \"#{PRODUCT_PLIST}\"` | |
`/usr/bin/plutil -convert binary1 \"#{PRODUCT_PLIST}\"` | |
# log | |
puts "--> Updated #{BUNDLE_VERSION} to #{REVISION}" | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment