Skip to content

Commit

Permalink
Change from using applescript to command line tools.
Browse files Browse the repository at this point in the history
Makes the gem to almost stupidly simple now. Bump to version 1.2.0
  • Loading branch information
markrickert committed Oct 11, 2019
1 parent 0b2d9e6 commit 906c837
Show file tree
Hide file tree
Showing 7 changed files with 8 additions and 58 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,3 +16,4 @@ nbproject
.sass-cache
.idea
.dat*.*
vendor
4 changes: 2 additions & 2 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
PATH
remote: .
specs:
reset-sim (1.2.0)
reset-sim (1.3.0)

GEM
remote: https://rubygems.org/
Expand All @@ -16,4 +16,4 @@ DEPENDENCIES
reset-sim!

BUNDLED WITH
1.10.4
2.0.2
8 changes: 2 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

Adds a command to terminal that lets you easily reset the iOS Simulator

Tested on Mojave & Xcode 10. Any other Mac OS, YMMV.
Tested on Mojave & Xcode 11. Any other Mac OS, YMMV.

## Installation

Expand All @@ -20,11 +20,7 @@ Or install it yourself as:

## Usage

Add your terminal application to System Preferences, Privacy, Accessibility options.

Then run `reset-sim` to reset the simulator.

![System Preferences](/screenshot.png)
Run `reset-sim` to reset the simulator.

## Contributing

Expand Down
37 changes: 1 addition & 36 deletions bin/reset-sim
Original file line number Diff line number Diff line change
@@ -1,38 +1,3 @@
#!/usr/bin/env ruby

def osascript(script)
system 'osascript', *script.split(/\n/).map { |line| ['-e', line] }.flatten
end

osascript <<-END
-- assume most people are on xcode7 or greater
-- so try that first
set simulator_app_name to missing value
try
tell application "Simulator" to activate
set simulator_app_name to "Simulator"
on error number -1728
log "Trying legacy iOS Simulator application..."
try
tell application "iOS Simulator" to activate
set simulator_app_name to "iOS Simulator"
on error number -1728
log "No Simulator application installed"
end try
end try
if simulator_app_name is not equal to missing value
tell application "System Events"
click menu item ¬
"Erase All Content and Settings…" of menu 1 of menu bar item ¬
"Hardware" of menu bar 1 of application process simulator_app_name
delay 0.5
tell process simulator_app_name
keystroke tab
keystroke return
end tell
end tell
end if
END
system 'killall "Simulator" 2> /dev/null && xcrun simctl erase all'
2 changes: 1 addition & 1 deletion lib/version.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module ResetSim
VERSION = "1.2.0"
VERSION = "1.3.0"
end
14 changes: 1 addition & 13 deletions reset-sim.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,8 @@ Gem::Specification.new do |spec|
spec.email = ["mjar81@gmail.com"]
spec.description = "Adds a command to terminal that lets you easily reset the iOS Simulator"
spec.summary = "Resets the iOS simulator"
spec.homepage = ""
spec.homepage = "https://github.com/OTGApps/reset-sim"
spec.license = "MIT"

spec.post_install_message = <<-END
********* IMPORTANT *********
In order to work properly you must add your terminal application in
System Preferences -> Privacy -> Accessibility options.
Then run: reset-sim
*****************************
END

spec.files = []
spec.require_paths = ["lib"]
spec.executables = ["reset-sim"]
Expand Down
Binary file removed screenshot.png
Binary file not shown.

0 comments on commit 906c837

Please sign in to comment.