105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
|
# File 'lib/run_loop/cli/simctl.rb', line 105
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)
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
|