Skip to content
Browse files

Add support for importing the provisioning profile from the cmd line

  • Loading branch information...
1 parent 244de0c commit 0ecf266561e63e007662aea79fed95c3447735c0 @rayh committed Oct 27, 2011
Showing with 56 additions and 5 deletions.
  1. +4 −0 .rvmrc
  2. +6 −4 lib/xcode/configuration.rb
  3. +20 −0 lib/xcode/shell.rb
  4. +1 −1 lib/xcode/version.rb
  5. +25 −0 lib/xcoder.rb
View
4 .rvmrc
@@ -0,0 +1,4 @@
+rvm use 1.9.2@xcoder
+rvm_install_on_use_flag=1
+rvm_project_rvmrc=1
+rvm_gemset_create_on_use_flag=1
View
10 lib/xcode/configuration.rb
@@ -1,3 +1,5 @@
+require 'xcode/shell'
+
module Xcode
class Configuration
attr_reader :target
@@ -48,7 +50,7 @@ def build
cmd << "-project \"#{@target.project.path}\""
cmd << "-target \"#{@target.name}\""
cmd << "-configuration \"#{name}\""
- execute(cmd)
+ Xcode::Shell.execute(cmd)
end
def clean
@@ -59,7 +61,7 @@ def clean
cmd << "-target \"#{@target.name}\""
cmd << "-configuration \"#{name}\""
cmd << "clean"
- execute(cmd)
+ Xcode::Shell.execute(cmd)
end
def sign(identity)
@@ -70,7 +72,7 @@ def sign(identity)
cmd << "--resource-rules=\"#{app_path}/ResourceRules.plist\""
cmd << "--entitlements \"#{entitlements_path}\""
cmd << "\"#{ipa_path}\""
- execute(cmd)
+ Xcode::Shell.execute(cmd)
end
def entitlements_path
@@ -101,7 +103,7 @@ def package(options={})
cmd << "--embed \"#{options[:profile]}\""
end
- execute(cmd)
+ Xcode::Shell.execute(cmd)
end
private
View
20 lib/xcode/shell.rb
@@ -0,0 +1,20 @@
+module Xcode
+ module Shell
+ def self.execute(bits, show_output=true)
+ out = []
+ cmd = bits.is_a?(Array) ? bits.join(' ') : bits
+
+ puts "EXECUTE: #{cmd}"
+ IO.popen (cmd) do |f|
+ f.each do |line|
+ puts line if show_output
+ out << line
+ end
+ end
+ #Process.wait
+ raise "Error (#{$?.exitstatus}) executing '#{cmd}'\n\n #{out.join(" ")}" if $?.exitstatus>0
+ #puts "RETURN: #{out.inspect}"
+ out
+ end
+ end
+end
View
2 lib/xcode/version.rb
@@ -1,3 +1,3 @@
module Xcode
- VERSION = "0.0.6"
+ VERSION = "0.0.7"
end
View
25 lib/xcoder.rb
@@ -3,6 +3,8 @@
require "xcode/version"
require "xcode/project"
require "xcode/info_plist"
+require "xcode/shell"
+require 'plist'
module Xcode
@@projects = nil
@@ -16,6 +18,29 @@ module Xcode
# raise "Unable to find project named #{name}"
# end
+ def self.import_certificate(cert, password, keychain="~/Library/Keychains/login.keychain")
+ cmd = []
+ cmd << "security"
+ cmd << "import '#{cert}'"
+ cmd << "-k #{keychain}"
+ cmd << "-P #{password}"
+ cmd << "-T /usr/bin/codesign"
+ Xcode::Shell.execute(cmd)
+ end
+
+ def self.import_provisioning_profile(profile)
+ uuid = nil
+ File.open(profile, "rb") do |f|
+ input = f.read
+ input=~/<key>UUID<\/key>.*<string>(.*)<\/string>/im
+ uuid = $1.strip
+ end
+
+ puts "Importing profile #{profile} with UUID #{uuid}"
+
+ Xcode::Shell.execute("cp #{profile} ~/Library/MobileDevice/Provisioning\\ Profiles/#{uuid}.mobileprovision")
+ end
+
def self.find_projects(dir='.')
parse_projects(dir)
end

0 comments on commit 0ecf266

Please sign in to comment.
Something went wrong with that request. Please try again.