Created
January 11, 2013 16:17
-
-
Save AquaGeek/4511899 to your computer and use it in GitHub Desktop.
Provisioning Profiles
This file contains hidden or 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
| #!/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