Skip to content

Instantly share code, notes, and snippets.

@georgkreimer
Created June 28, 2012 17:34
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save georgkreimer/3012716 to your computer and use it in GitHub Desktop.
Save georgkreimer/3012716 to your computer and use it in GitHub Desktop.
Configure Mobile Safari on the Simulator allow remote debugging of web pages and open safari to view the inspector.
#!/bin/sh
#
# Configure Mobile Safari on the Simulator allow remote debugging of web pages
# and open safari to view the inspector.
#
# If you want to open the Simulator from the command line you might like the
# following alias:
# alias iphone-simulator="open /Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app"
#
pid=$(ps x | egrep "MobileSafari|Web.app" | grep -v grep | awk '{ print $1 }')
if [ "$pid" == "" ]; then
echo "Safari.app must be running in the Simulator to enable the remote inspector."
else
cat <<EOS | gdb -quiet > /dev/null
attach $pid
p (void *)[WebView _enableRemoteInspector]
detach
EOS
osascript <<EOS > /dev/null 2>&1
tell application "Safari"
activate
do JavaScript "window.open('http://localhost:9999')" in document 1
end tell
EOS
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment