158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
|
# File 'lib/run_loop/cli/simctl.rb', line 158
def install
debug = options[:debug]
if debug
ENV['DEBUG'] = '1'
end
debug_logging = RunLoop::Environment.debug?
device = expect_device(options)
app = expect_app(options, device)
bridge = RunLoop::Simctl::Bridge.new(device, app.path)
xcode = bridge.sim_control.xcode
if xcode.version >= RunLoop::Version.new('7.0')
puts "ERROR: Xcode #{xcode.version.to_s} detected."
puts "ERROR: Apple's simctl install/uninstall is broken for this version of Xcode."
puts "ERROR: See the following links for details:"
puts "ERROR: https://forums.developer.apple.com/message/51922"
puts "ERROR: https://github.com/calabash/run_loop/issues/235"
puts "ERROR: exiting 1"
exit 1
end
force_reinstall = options[:force]
before = Time.now
if bridge.app_is_installed?
if debug_logging
puts "App with bundle id '#{app.bundle_identifier}' is already installed."
end
if force_reinstall
if debug_logging
puts 'Will force a re-install.'
end
bridge.uninstall
bridge.install
else
new_digest = RunLoop::Directory.directory_digest(app.path)
if debug_logging
puts " New app has SHA: '#{new_digest}'."
end
installed_app_bundle = bridge.fetch_app_dir
old_digest = RunLoop::Directory.directory_digest(installed_app_bundle)
if debug_logging
puts "Installed app has SHA: '#{old_digest}'."
end
if new_digest != old_digest
if debug_logging
puts "Will re-install '#{app.bundle_identifier}' because the SHAs don't match."
end
bridge.uninstall
bridge.install
else
if debug_logging
puts "Will not re-install '#{app.bundle_identifier}' because the SHAs match."
end
end
end
else
bridge.install
end
if debug_logging
"Launching took #{Time.now-before} seconds"
puts "Installed '#{app.bundle_identifier}' on #{device} in #{Time.now-before} seconds."
end
end
|