Skip to content

Instantly share code, notes, and snippets.

@jakemarsh
Created January 20, 2012 14:57
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save jakemarsh/1647709 to your computer and use it in GitHub Desktop.
Save jakemarsh/1647709 to your computer and use it in GitHub Desktop.
Simple Applescript that can be run from the command line to programmatically reset the iOS simulator.
tell application "iPhone Simulator"
activate
end tell
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
tell window 1
click button "Reset"
end tell
end tell
end tell
-- Run at the command line or from a shell script using something like: 'osascript reset_simulator.applescript'
@RussVanBert
Copy link

In Mavericks, it was not finding the Reset button. I changed the line to "click button 1" and it worked.

@swl367
Copy link

swl367 commented Jul 9, 2014

+1 RussVanBert's comment

@hsylife
Copy link

hsylife commented Jun 3, 2015

In Yosemite + iOS Simulator 8.3, I changed the string of "iPhone Simulator" to "iOS Simulator" and it worked.

@danstepanov
Copy link

danstepanov commented May 8, 2016

Updated for El Capitan (10.11.4), Xcode Version 7.3.1, iOS Simulator Version 9.3

tell application "Simulator"
    activate
end tell

tell application "System Events"
    tell process "Simulator"
        tell menu bar 1
            tell menu bar item "Simulator"
                tell menu "Simulator"
                    click menu item "Reset Content and Settings…"
                end tell
            end tell
        end tell
        tell window 1
            click button "Reset"
        end tell
    end tell
end tell

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment