Skip to content

Commit cd4cdec

Browse files
committed
Merge pull request moredip#11 from calabash/master
Support for starting simulator without launch
2 parents 2cedf01 + fdb1b32 commit cd4cdec

File tree

4 files changed

+41
-1
lines changed

4 files changed

+41
-1
lines changed

lib/sim_launcher/simulator.rb

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,28 @@ def showsdks
99
run_synchronous_command( 'showsdks' )
1010
end
1111

12+
def start_simulator(sdk_version=nil, device_family="iphone")
13+
sdk_version ||= SdkDetector.new(self).latest_sdk_version
14+
run_synchronous_command( :start, '--sdk', sdk_version, '--family', device_family, '--exit' )
15+
end
16+
17+
def reset(sdks=nil)
18+
script_dir = File.join(File.dirname(__FILE__),"..","..","scripts")
19+
reset_script = File.expand_path("#{script_dir}/reset_simulator.applescript")
20+
21+
sdks ||= SimLauncher::SdkDetector.new(self).available_sdk_versions
22+
23+
sdks.each do |sdk_path_str|
24+
start_simulator(sdk_path_str,"iphone")
25+
system("osascript #{reset_script}")
26+
start_simulator(sdk_path_str,"ipad")
27+
system("osascript #{reset_script}")
28+
end
29+
30+
quit_simulator
31+
32+
end
33+
1234
def launch_ios_app(app_path, sdk_version, device_family, app_args = nil)
1335
if problem = SimLauncher.check_app_path( app_path )
1436
bangs = '!'*80

lib/sim_launcher/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module SimLauncher
2-
VERSION = "0.4.6"
2+
VERSION = "0.4.7"
33
end

native/ios-sim

-7.97 KB
Binary file not shown.

scripts/reset_simulator.applescript

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
tell application "System Events"
2+
3+
tell process "iPhone Simulator"
4+
5+
tell menu bar 1
6+
tell menu bar item "iOs Simulator"
7+
tell menu "iOs Simulator"
8+
click menu item "Reset Content and SettingsÉ"
9+
end tell
10+
end tell
11+
end tell
12+
delay 1
13+
perform action "AXRaise" of window 1
14+
tell window 1
15+
click button "Reset"
16+
end tell
17+
end tell
18+
end tell

0 commit comments

Comments
 (0)