Skip to content

Commit

Permalink
Move execution of cmd line stuff to configuration, add codesign stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
rayh committed Aug 19, 2011
1 parent 372e0c8 commit 46059de
Show file tree
Hide file tree
Showing 3 changed files with 43 additions and 38 deletions.
45 changes: 42 additions & 3 deletions lib/xcode/configuration.rb
Expand Up @@ -24,9 +24,28 @@ def info_plist


def build def build
cmd = [] cmd = []
cmd << "xcodebuild"
cmd << "-sdk #{@target.project.sdk}" unless @target.project.sdk.nil?
cmd << "-project \"#{@target.project.path}\""
cmd << "-target \"#{@target.name}\"" cmd << "-target \"#{@target.name}\""
cmd << "-configuration \"#{name}\"" cmd << "-configuration \"#{name}\""
@target.project.execute_xcodebuild(cmd.join(' ')) execute(cmd)
end


def sign(identity)
cmd = []
cmd << "codesign"
cmd << "--force"
cmd << "--sign \"#{identity}\""
cmd << "--resource-rules=\"#{app_path}/ResourceRules.plist\""
cmd << "--entitlements \"#{entitlements_path}\""
cmd << "\"#{ipa_path}\""
execute(cmd)
end

def entitlements_path
"#{File.dirname(@target.project.path)}/build/#{@target.productName}.build/#{name}-#{@target.project.sdk}/#{@target.productName}.build/#{@target.productName}.xcent"
end end


def app_path def app_path
Expand All @@ -38,7 +57,10 @@ def ipa_path
end end


def package(options={}) def package(options={})
cmd = [] cmd = []
cmd << "xcrun"
cmd << "-sdk #{@target.project.sdk.nil? ? "iphoneos" : @target.project.sdk}"
cmd << "PackageApplication"
cmd << "-v \"#{app_path}\"" cmd << "-v \"#{app_path}\""
cmd << "-o \"#{ipa_path}\"" cmd << "-o \"#{ipa_path}\""


Expand All @@ -50,7 +72,24 @@ def package(options={})
cmd << "--embed \"#{options[:profile]}\"" cmd << "--embed \"#{options[:profile]}\""
end end


@target.project.execute_package_application(cmd.join(' ')) execute(cmd)
end

private

def execute(bits, show_output=true)
out = []
cmd = bits.join(' ')
puts "EXECUTE: #{cmd}"
IO.popen (cmd) do |f|
f.each do |line|
puts line if show_output
out << line
end
end
#puts "RETURN: #{out.inspect}"
out
end end

end end
end end
34 changes: 0 additions & 34 deletions lib/xcode/project.rb
Expand Up @@ -13,27 +13,6 @@ def initialize(path, sdk=nil)
parse_pbxproj parse_pbxproj
# parse_configurations # parse_configurations
end end

def execute_package_application(options=nil)
cmd = []
cmd << "xcrun"
cmd << "-sdk #{@sdk.nil? ? "iphoneos" : @sdk}"
cmd << "PackageApplication"
cmd << options unless options.nil?

execute(cmd.join(' '), true)
end

def execute_xcodebuild(cmd_line=nil, show_output=true)
cmd = []
cmd << "xcodebuild"
cmd << "-sdk #{@sdk}" unless @sdk.nil?
cmd << "-project \"#{@path}\""
cmd << cmd_line unless cmd_line.nil?
yield cmd if block_given?

execute(cmd.join(' '), show_output)
end


def target(name) def target(name)
target = @targets[name.to_s.to_sym] target = @targets[name.to_s.to_sym]
Expand Down Expand Up @@ -62,19 +41,6 @@ def parse_pbxproj
@targets[target.name.to_sym] = target @targets[target.name.to_sym] = target
end end
end end

def execute(cmd, show_output=false)
out = []
puts "EXECUTE: #{cmd}"
IO.popen (cmd) do |f|
f.each do |line|
puts line if show_output
out << line
end
end
#puts "RETURN: #{out.inspect}"
out
end


end end
end end
2 changes: 1 addition & 1 deletion lib/xcode/version.rb
@@ -1,3 +1,3 @@
module Xcode module Xcode
VERSION = "0.0.2" VERSION = "0.0.3"
end end

0 comments on commit 46059de

Please sign in to comment.