Skip to content

Instantly share code, notes, and snippets.

@masuidrive
Created September 6, 2011 16:42
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save masuidrive/1198113 to your computer and use it in GitHub Desktop.
Save masuidrive/1198113 to your computer and use it in GitHub Desktop.
Download iOS provisioning file from DevCenter.
#!/usr/bin/env ruby
unless ARGV.length == 3
puts "Usage: ruby #{__FILE__} \"Provisioning Profile\" \"Apple ID\" \"Password\""
puts "Require Mechanize gem. plz run \"sudo gem install mechanize\""
exit 1
end
require 'rubygems'
require 'mechanize'
require 'fileutils'
TMP_PROVISIONING_FILE = File.join(Dir.tmpdir, "test.mobileprovision")
a = Mechanize.new { |agent|
agent.follow_meta_refresh = true
}
a.get('http://developer.apple.com/iphone/login.action') do |signin_page|
# login
my_page = signin_page.form_with(:name => 'appleConnectForm') do |form|
form.theAccountName = ARGV[1]
form.theAccountPW = ARGV[2]
end.submit
# access to provisioning
provisioning_href = nil
a.get('/ios/manage/provisioningprofiles/index.action') do |page|
page.search('.nt_multi tr').each do |line|
name = line.search(".profile span").text
if ARGV[0]==name
# download provisioning
line.search(".action a").each do |link|
if %r|/ios/manage/provisioningprofiles/download.action|.match(link['href'])
# write to file
a.get(link['href']) do |page|
open(TMP_PROVISIONING_FILE, 'w') do |f|
f.write page.body
end
# install to XCode
`open #{TMP_PROVISIONING_FILE}`
end
end
end
end # if ARGV[0]==name
end # page.search('.nt_multi tr')
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment