21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
# File 'lib/utils/xcode_simulator.rb', line 21
def install_app(ipa_path)
raise "Non-IPA file provided: #{ipa_path}" unless ipa_path.end_with?('.ipa')
Dir.mktmpdir do |tmp_dir|
Logger.debug "Extracting .app from .ipa in temporary directory: #{tmp_dir}"
Zip::File.open(ipa_path) do |zip_file|
Logger.debug 'IPA contents:'
zip_file.each do |entry|
Logger.debug " #{entry.name}"
end
app_entry = zip_file.glob('**/*.app/').first ||
zip_file.glob('**/*.app').first ||
zip_file.find { |entry| entry.name.end_with?('.app/') || entry.name.end_with?('.app') }
raise 'No .app found in .ipa file' unless app_entry
Logger.debug "Found app entry: #{app_entry.name}"
app_dir = app_entry.name.end_with?('/') ? app_entry.name.chomp('/') : app_entry.name
pattern = "#{File.dirname(app_dir)}/#{File.basename(app_dir)}/**/*"
Logger.debug "Using glob pattern: #{pattern}"
zip_file.glob(pattern).each do |entry|
entry_path = File.join(tmp_dir, entry.name)
FileUtils.mkdir_p(File.dirname(entry_path))
zip_file.(entry, entry_path) unless File.exist?(entry_path)
end
= Dir.glob(File.join(tmp_dir, '**/*.app')).first
raise 'Failed to extract .app from .ipa' unless
Logger.debug "Extracted app at: #{}"
()
end
end
end
|