Class: UISpecRunner::XcodeBuilder

Inherits:
Object
  • Object
show all
Defined in:
lib/uispecrunner/xcode_builder.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(config) ⇒ XcodeBuilder

Returns a new instance of XcodeBuilder.



5
6
7
# File 'lib/uispecrunner/xcode_builder.rb', line 5

def initialize(config)
  @config = config
end

Instance Attribute Details

#app_pathObject (readonly)

Returns the value of attribute app_path.



3
4
5
# File 'lib/uispecrunner/xcode_builder.rb', line 3

def app_path
  @app_path
end

#configObject (readonly)

Returns the value of attribute config.



3
4
5
# File 'lib/uispecrunner/xcode_builder.rb', line 3

def config
  @config
end

Instance Method Details

#build!Object



9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
# File 'lib/uispecrunner/xcode_builder.rb', line 9

def build!
  command = "xcodebuild #{workspace_switch} #{scheme_switch} #{project_switch} #{target_switch} -configuration #{config.configuration} #{sdk_switch}"
  puts "Building project with: #{command}" if config.verbose?
  status = Open4::popen4(command) do |pid, stdin, stdout, stderr|
    stdout.each_line do |line|
      if line =~ /^Touch\s/
        @app_path = line.split(/^Touch\s/).last.chomp
        puts "*** Found app path: #{self.app_path}" if config.verbose?
      end
      puts line if config.verbose?
    end
    
    stderr.each_line do |line|
      puts line
    end
  end
  puts "Exited with status: #{ status.exitstatus }" if config.verbose? || status.exitstatus != 0
  return status.exitstatus
end