class Calasmash::Compiler
The calamsash compiler will compiles the Xcode project with the scheme it's told to compile with.
@author [alexfish]
Attributes
scheme[RW]
Public: the Scheme the compiler is compiling
Public Class Methods
new(scheme)
click to toggle source
# File lib/calasmash/compiler.rb, line 16 def initialize(scheme) @scheme = scheme end
Public Instance Methods
compile(&complete)
click to toggle source
The compiler's heart, executes the compiling with xcodebuild
@param &complete Compleition block
Returns nothing because it completes with a complete block
# File lib/calasmash/compiler.rb, line 26 def compile(&complete) started status = nil output = "" Open3.popen3 command do |stdin, out, err, wait_thr| [out, err].each do |stream| Thread.new do until (line = stream.gets).nil? do print "." output << line end end end wait_thr.join status = wait_thr.value.exitstatus end if status != 0 puts "\nCompilation failed: \n\n #{output}" exit status else completed complete.call(true) if complete end end
Private Instance Methods
command()
click to toggle source
Generate the string to be used as the xcode build command using the scheme ivar
@return [String] The full xcode build command with args
# File lib/calasmash/compiler.rb, line 75 def command xcode_command = "xcodebuild -workspace #{workspace} \ -scheme #{@scheme} \ -sdk iphonesimulator \ CODE_SIGN_IDENTITY="" \ CODE_SIGNING_REQUIRED=NO" xcode_command end
completed()
click to toggle source
Output a nice message for completing
# File lib/calasmash/compiler.rb, line 66 def completed puts "\nCompiled 👌" end
started()
click to toggle source
Output a nice message for starting
# File lib/calasmash/compiler.rb, line 58 def started puts "\nCompiling" puts "=========\n" end
workspace()
click to toggle source
Looks in the current directory for the workspace file and gets it's name
@return [String] The name of the workspace file that was found
# File lib/calasmash/compiler.rb, line 90 def workspace Dir["*.xcworkspace"].first end