diff --git a/lib/sim_launcher/simulator.rb b/lib/sim_launcher/simulator.rb index c7913f5..49c9ec7 100644 --- a/lib/sim_launcher/simulator.rb +++ b/lib/sim_launcher/simulator.rb @@ -9,6 +9,28 @@ def showsdks run_synchronous_command( 'showsdks' ) end + def start_simulator(sdk_version=nil, device_family="iphone") + sdk_version ||= SdkDetector.new(self).latest_sdk_version + run_synchronous_command( :start, '--sdk', sdk_version, '--family', device_family, '--exit' ) + end + + def reset(sdks=nil) + script_dir = File.join(File.dirname(__FILE__),"..","..","scripts") + reset_script = File.expand_path("#{script_dir}/reset_simulator.applescript") + + sdks ||= SimLauncher::SdkDetector.new(self).available_sdk_versions + + sdks.each do |sdk_path_str| + start_simulator(sdk_path_str,"iphone") + system("osascript #{reset_script}") + start_simulator(sdk_path_str,"ipad") + system("osascript #{reset_script}") + end + + quit_simulator + + end + def launch_ios_app(app_path, sdk_version, device_family, app_args = nil) if problem = SimLauncher.check_app_path( app_path ) bangs = '!'*80 diff --git a/lib/sim_launcher/version.rb b/lib/sim_launcher/version.rb index 25cc554..57606b2 100644 --- a/lib/sim_launcher/version.rb +++ b/lib/sim_launcher/version.rb @@ -1,3 +1,3 @@ module SimLauncher - VERSION = "0.4.6" + VERSION = "0.4.7" end diff --git a/native/ios-sim b/native/ios-sim index 7068d8c..8b33992 100755 Binary files a/native/ios-sim and b/native/ios-sim differ diff --git a/scripts/reset_simulator.applescript b/scripts/reset_simulator.applescript new file mode 100644 index 0000000..11b0632 --- /dev/null +++ b/scripts/reset_simulator.applescript @@ -0,0 +1,18 @@ +tell application "System Events" + + tell process "iPhone Simulator" + + tell menu bar 1 + tell menu bar item "iOs Simulator" + tell menu "iOs Simulator" + click menu item "Reset Content and SettingsÉ" + end tell + end tell + end tell + delay 1 + perform action "AXRaise" of window 1 + tell window 1 + click button "Reset" + end tell + end tell +end tell \ No newline at end of file