Last active
January 28, 2016 03:36
-
-
Save jimmont/49da1c393fdb346b492c to your computer and use it in GitHub Desktop.
launch cordova iOS emulator then debug in Safari with a single alias
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* | |
| based on https://gist.github.com/bwdolphin/e7de2d0a21914708bd9a | |
| setup: | |
| open /Applications/Utilities/Script Editor | |
| edit and save | |
| System Prefs > Security & Privacy > [Privacy tab] > Accessibility in left sidebar | |
| -> add [+] this new app (NOTE must repeat this addition every time the app/script is saved/changed to avoid security errrors) | |
| run (eg in the terminal): | |
| % cordova run ios && open ./path/to/debugiOS.app/ | |
| -> cordova runs, emulator opens, script runs, Safari opens while app launches, after the delay try to open debugger | |
| Note the delay isn't intelligent and might need to be adjusted depending. | |
| */ | |
| tell application "Safari" | |
| activate | |
| delay 0.5 | |
| tell application "System Events" | |
| tell process "Safari" | |
| set frontmost to true | |
| delay 0.5 | |
| delay 4 | |
| if (menu item "Favorites" of menu 1 of menu bar item "Window" of menu bar 1 exists) then | |
| click menu item "Favorites" of menu 1 of menu bar item "Window" of menu bar 1 | |
| click menu item "Close Window" of menu 1 of menu bar item "File" of menu bar 1 | |
| end if | |
| if ((menu item "Simulator" of menu 1 of menu bar item "Develop" of menu bar 1 exists) and (not (menu item "No Inspectable Applications" of menu 1 of menu item "Simulator" of menu 1 of menu bar item "Develop" of menu bar 1 exists))) then | |
| click menu item 2 of menu 1 of menu item "Simulator" of menu 1 of menu bar item "Develop" of menu bar 1 | |
| delay 1 | |
| keystroke "r" using {command down} | |
| end if | |
| if ((menu item "iPhone" of menu 1 of menu bar item "Develop" of menu bar 1 exists) and (not (menu item "No Inspectable Applications" of menu 1 of menu item "iPhone" of menu 1 of menu bar item "Develop" of menu bar 1 exists))) then | |
| click menu item 2 of menu 1 of menu item "iPhone" of menu 1 of menu bar item "Develop" of menu bar 1 | |
| delay 1 | |
| keystroke "r" using {command down} | |
| end if | |
| end tell | |
| end tell | |
| end tell |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment