Module: SimLauncher
- Defined in:
- lib/sim_launcher.rb,
lib/sim_launcher/client.rb,
lib/sim_launcher/version.rb,
lib/sim_launcher/simulator.rb,
lib/sim_launcher/sdk_detector.rb,
lib/sim_launcher/direct_client.rb
Defined Under Namespace
Classes: Client, DirectClient, SdkDetector, Simulator
Constant Summary
collapse
- DERIVED_DATA =
File.expand_path("~/Library/Developer/Xcode/DerivedData")
- DEFAULT_DERIVED_DATA_INFO =
File.expand_path("#{DERIVED_DATA}/*/info.plist")
- VERSION =
"0.5.0"
Class Method Summary
collapse
Class Method Details
.app_bundle_or_raise(path) ⇒ Object
68
69
70
71
72
73
74
75
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
|
# File 'lib/sim_launcher.rb', line 68
def self.app_bundle_or_raise(path)
bundle_path = nil
if path and not File.directory?(path)
puts "Unable to find .app bundle at #{path}. It should be an .app directory."
dd_dir = derived_data_dir_for_project_name(path)
app_bundles = Dir.glob(File.join(dd_dir, "Build", "Products", "*", "*.app"))
msg = "sim_launcher found the following bundles:\n\n"
msg << app_bundles.join("\n")
raise msg
elsif path
bundle_path = path
else
dd_dir = derived_data_dir_for_project_name(path)
sim_dirs = Dir.glob(File.join(dd_dir, "Build", "Products", "*-iphonesimulator", "*.app"))
if sim_dirs.empty?
msg = ["Unable to auto detect bundle."]
msg << "Have you built your app for simulator?."
msg << "Searched dir: #{dd_dir}/Build/Products"
msg << "Please build your app from Xcode\n"
raise msg.join("\n")
end
preferred_dir = find_preferred_dir(sim_dirs)
if preferred_dir.nil?
msg = ["Error... Unable to find bundle."]
msg << "Cannot find a built app that is linked with calabash.framework"
msg << "Please build your app from Xcode"
msg << "You should build your calabash target.\n"
raise msg.join("\n")
end
puts("-"*37)
puts "Auto detected bundle:\n\n"
puts "bundle = #{preferred_dir || sim_dirs[0]}\n\n"
puts "Please verify!"
puts("-"*37)
bundle_path = sim_dirs[0]
end
bundle_path
end
|
.check_app_path(app_path) ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
# File 'lib/sim_launcher.rb', line 11
def self.check_app_path( app_path )
unless File.exists?( app_path )
return "The specified app path doesn't seem to exist: #{app_path}"
end
unless File.directory? app_path
file_appears_to_be_a_binary = !!( `file "#{app_path}"` =~ /Mach-O executable/ )
if file_appears_to_be_a_binary
return <<-EOS
The specified app path is a binary executable, rather than a directory. You need to provide the path to the app *bundle*, not the app executable itself.
The path you specified was: #{app_path}
You might want to instead try specifying: #{File.dirname(app_path)}
EOS
else
return "The specified app path is not a directory. You need to provide the path to your app bundle.\nSpecified app path was: #{app_path}"
end
end
nil
end
|
.derived_data_dir_for_project_name(project_name) ⇒ Object
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
61
62
63
64
65
66
|
# File 'lib/sim_launcher.rb', line 32
def self.derived_data_dir_for_project_name(project_name)
build_dirs = Dir.glob("#{DERIVED_DATA}/*").find_all do |xc_proj|
File.basename(xc_proj).start_with?(project_name)
end
if (build_dirs.count == 0 && !project_name.empty?)
build_dirs = Dir.glob("#{DERIVED_DATA}/*").find_all do |xc_proj|
File.basename(xc_proj).downcase.start_with?(project_name)
end
end
puts build_dirs
if (build_dirs.count == 0)
msg = ["Unable to find your built app."]
msg << "This means that sim_launcher can't automatically launch the build for the #{project_name}."
msg << "Searched in Xcode 4.x default: #{DERIVED_DATA}"
raise msg.join("\n")
elsif (build_dirs.count > 1)
msg = ["Unable to auto detect bundle."]
msg << "You have several projects with the same name: #{project_name} in #{DERIVED_DATA}:\n"
msg << build_dirs.join("\n")
msg << "\n\nThis means that sim_launcher can't automatically launch iOS simulator."
msg << "Searched in Xcode 4.x default: #{DEFAULT_DERIVED_DATA_INFO}\n"
raise msg.join("\n")
else
puts "Found potential build dir: #{build_dirs.first}"
puts "Checking..."
return build_dirs.first
end
end
|