Skip to content

Instantly share code, notes, and snippets.

@mps
Last active December 18, 2015 15:49
Show Gist options
  • Save mps/5807196 to your computer and use it in GitHub Desktop.
Save mps/5807196 to your computer and use it in GitHub Desktop.
A rake task for revving plist build version numbers...
def revBuild(plistFile)
puts "Attempting to update #{plistFile} build version..."
oldVersion = `/usr/libexec/PlistBuddy -c "Print CFBundleVersion" #{plistFile}`
puts "The old version: #{oldVersion}"
versionParts = oldVersion.split(".")
previousDate = versionParts[2]
newDate = Time.now.strftime("%Y%m%d")
versionParts[2] = newDate
versionParts[3] = previousDate == versionParts[2] ? (versionParts[3].to_i+1).to_s : "1"
versionParts.each do |part|
part.chomp!
end
newVersion = versionParts.join(".")
`/usr/libexec/PlistBuddy -c "Set :CFBundleVersion #{newVersion}" #{plistFile}`
puts "The new version: #{newVersion}"
end
desc "Rev the build numbers in a project's plist"
task :rev do
revBuild './path/to/my.plist'
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment