Skip to content

Instantly share code, notes, and snippets.

@AquaGeek
Created January 11, 2013 16:17
Show Gist options
  • Select an option

  • Save AquaGeek/4511899 to your computer and use it in GitHub Desktop.

Select an option

Save AquaGeek/4511899 to your computer and use it in GitHub Desktop.
Provisioning Profiles
#!/usr/bin/env ruby
require 'FileUtils'
# Grab all of the profiles in [REPO]/Deployment/Provisioning and copy them to /Library/MobileDevice/Provisioning Profiles
DEPLOYMENT_DIR = File.join(ENV['PROJECT_DIR'], '..', '..', 'Deployment')
def install_provisioning_profile(profile)
raise "File not found" unless File.exists?(profile)
udid = extract_udid(profile)
destination = "#{ENV['HOME']}/Library/MobileDevice/Provisioning Profiles/#{udid}.mobileprovision"
if File.exists?(destination)
puts " Provisioning profile already exists"
else
puts " Installing..."
FileUtils.copy(profile, destination)
end
end
def extract_udid(profile)
contents = File.open(profile, "rb:ASCII-8BIT") do |f|
f.read
end
contents[/([A-Z0-9]{8}-(?:[A-Z0-9]{4}-){3}[A-Z0-9]{12})/]
end
puts "Installing provisioning profiles in #{DEPLOYMENT_DIR}/Provisioning"
Dir["#{DEPLOYMENT_DIR}/Provisioning/*.mobileprovision"].each do |f|
puts "=> #{File.basename(f)}"
install_provisioning_profile(f)
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment