-
Notifications
You must be signed in to change notification settings - Fork 1
/
ios-sim-inspector
executable file
·50 lines (44 loc) · 1.43 KB
/
ios-sim-inspector
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#!/bin/sh
ios-sim-inspector() {
if [ $# -eq 0 ]; then
printf "\n Usage: $ ios-sim-inspector <index-page-title>\n\n"
printf " * <index-page-title> cannot have the same name as the folder containing it :(\n\n"
else
appName="$1"
# Safari has been very stubborn about reloading "Develop" menu
# so, we force it to quit first :(
killall Safari
osascript <<EOF
# Name of the device as visible in Safari->Develop menu
set deviceName to "Simulator"
# Number of seconds to wait for the simulator window to show up
set maxWait to 10
set hasClicked to false
set x to 0
tell application "Safari"
activate
repeat until hasClicked or x > (maxWait * 10)
try
tell application "System Events"
click menu item "$appName" of menu deviceName of menu item deviceName of menu "Develop" of menu bar item "Develop" of menu bar 1 of application process "Safari"
end tell
set hasClicked to true
on error foo
delay 0.1
set x to x + 1
end try
end repeat
if hasClicked = false then
display dialog "Unable to connect to iOS simulator - make sure that it's working" buttons {"OK"} default button 1
else
try
tell application "System Events"
click button 1 of window "Favorites" of application process "Safari"
end tell
end try
return
end if
end tell
EOF
fi
}