Skip to content

Instantly share code, notes, and snippets.

@buritica
Created March 29, 2012 18:52
Show Gist options
  • Star 40 You must be signed in to star a gist
  • Fork 6 You must be signed in to fork a gist
  • Save buritica/2241976 to your computer and use it in GitHub Desktop.
Save buritica/2241976 to your computer and use it in GitHub Desktop.
Enable Remote Inspector on Mobile Safari
#!/bin/bash
# Open iPhone Simulator on default location for XCode 4.3 if found
[[ -d /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app/ ]] &&
open /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app
# Open iPhone Simulator on default location for XCode 4.2 if found
[[ -d /Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app/ ]] &&
open /Developer/Platforms/iPhoneSimulator.platform/Developer/Applications/iPhone\ Simulator.app
# Open mobile safari
echo Open mobile safari on emulator and press return
read
# Plug debug to MobileSafari.app
echo Debugging
MobileSafari_PID=$(ps x | grep "MobileSafari" | grep -v grep | awk '{ print $1 }')
if [ "$MobileSafari_PID" == "" ]; then
echo "Mobile Safari.app must be running in the Simulator to enable the remote inspector."
exit
else
cat <<EOM | gdb -quiet > /dev/null
attach $MobileSafari_PID
p (void *)[WebView _enableRemoteInspector]
detach
EOM
fi
# Open debugger in Safari.app
open -a /Applications/Safari.app http://localhost:9999
@novocaine
Copy link

i get an empty page with xcode 4.3, safari 6.

on chrome 21 i see the same error "Error during WebSocket handshake: 'Sec-WebSocket-Accept' header is missing". in safari i see no errors, but it looks like actually the same thing is happening.

i suspect the safari 6 upgrade has caused the problem given this was previously working for me.

@chaffeqa
Copy link

@novocaine I get the same error

@rangeoshun
Copy link

Same error here as reported by novocaine and chaffeqa.

@bluecontainer
Copy link

You need to use an earlier version of webkit that supports an earlier version of websockets. See http://www.iwebinspector.com/help.html#ml

@a-x-
Copy link

a-x- commented Feb 29, 2016

my path:
/Applications/Xcode.app/Contents/Developer/Applications/Simulator.app/Contents/MacOS/Simulator

@a-x-
Copy link

a-x- commented Feb 29, 2016

hmm

Unable to find Mach task port for process-id 55962: (os/kern) failure (0x5).
 (please check gdb is codesigned - see taskgated(8))
A syntax error in expression, near `[WebView _enableRemoteInspector]'.

@a-x-
Copy link

a-x- commented Feb 29, 2016

gdb installed with brew

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment