Skip to content

Instantly share code, notes, and snippets.

@norio-nomura
Created April 22, 2010 06:48
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 norio-nomura/374900 to your computer and use it in GitHub Desktop.
Save norio-nomura/374900 to your computer and use it in GitHub Desktop.
Ad Hoc なら CFBundleVersion を増やす
#!/usr/bin/env ruby
#
# gem install plist
#
# On Xcode, right-click on your Target where you want to use this and select
# Add->New Build Phase->New Run Script Build Phase.
#
# Set the Shell to
# /usr/bin/ruby
#
# And paste this script.
#
require 'rubygems'
require 'plist'
exit if ENV['CONFIGURATION'] != "Ad Hoc"
current_plist_file = "#{ENV['PROJECT_DIR']}/#{ENV['INFOPLIST_FILE']}"
current_plist_hash = Plist::parse_xml(current_plist_file)
current_version_array = current_plist_hash['CFBundleVersion'].split(".")
current_version_array.push(current_version_array.pop.to_i + 1).to_s
current_plist_hash['CFBundleVersion'] = current_version_array.join(".")
File.open(current_plist_file, 'w') {|f| f.write(current_plist_hash.to_plist) }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment