Created
October 25, 2016 16:17
-
-
Save bdnelson/a531eb5996a3b194bfeda06d44ac4d8e to your computer and use it in GitHub Desktop.
Set Simulator GPS Location
This file contains 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
#!/bin/bash | |
if [ $# -lt 2 ]; then | |
echo "$0 <latitude> <longitude> [altitude] [portNum]" | |
exit | |
fi | |
port="5554" | |
altitude="100" | |
auth_key=`cat $HOME/.emulator_console_auth_token | awk '{print $1}'` | |
latitude=$1 | |
longitude=$2 | |
if [ $# -gt 2 ]; then | |
altitude=$3 | |
fi | |
if [ $# -gt 3 ]; then | |
port=$4 | |
fi | |
echo "Setting Android Sim location to ($latitude, $longitude, $altitude)" | |
expect <<- DONE | |
spawn telnet localhost $port | |
expect "OK" | |
send "auth $auth_key\r" | |
expect "OK" | |
send "geo fix $longitude $latitude $altitude\r" | |
expect "OK" | |
send "exit\r" | |
DONE |
This file contains 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
#!/bin/bash | |
if [ $# -lt 2 ]; then | |
echo "$0 <latitude> <longitude>" | |
exit | |
fi | |
latitude=$1 | |
longitude=$2 | |
echo "Setting iOS Sim location to ($latitude, $longitude)" | |
osascript <<DONE | |
tell application "System Events" | |
tell process "Simulator" | |
tell menu bar 1 | |
tell menu bar item "Debug" | |
tell menu "Debug" | |
tell menu item "Location" | |
click | |
tell menu "Location" | |
click menu item "Custom Location…" | |
end tell | |
end tell | |
end tell | |
end tell | |
end tell | |
tell window 1 | |
set value of text field 1 to "$latitude" | |
set value of text field 2 to "$longitude" | |
click button "OK" | |
end tell | |
end tell | |
end tell | |
DONE |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment