Method: RunLoop.run

Defined in:
lib/run_loop.rb

.run(options = {}) ⇒ Object



76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
# File 'lib/run_loop.rb', line 76

def self.run(options={})

  cloned_options = options.clone

  # We want to use the _exact_ objects that were passed.
  if options[:xcode]
    cloned_options[:xcode] = options[:xcode]
  else
    cloned_options[:xcode] = RunLoop::Xcode.new
  end

  if options[:simctl]
    cloned_options[:simctl] = options[:simctl]
  else
    cloned_options[:simctl] = RunLoop::Simctl.new
  end

  if options[:instruments]
    cloned_options[:instruments] = options[:instruments]
  else
    cloned_options[:instruments] = RunLoop::Instruments.new
  end

  # Soon to be unsupported.
  if options[:sim_control]
    cloned_options[:sim_control] = options[:sim_control]
  end

  xcode = cloned_options[:xcode]
  simctl = cloned_options[:simctl]
  instruments = cloned_options[:instruments]

  device = Device.detect_device(cloned_options, xcode, simctl, instruments)
  cloned_options[:device] = device

  automator = RunLoop.detect_automator(cloned_options, xcode, device)
  if automator == :device_agent
    RunLoop::DeviceAgent::Client.run(cloned_options)
  else
    if RunLoop::Instruments.new.instruments_app_running?
      raise %q(The Instruments.app is open.

If the Instruments.app is open, the instruments command line tool cannot take
control of your application.

Please quit the Instruments.app and try again.)

    end
    Core.run_with_options(cloned_options)
  end
end