Skip to content

Instantly share code, notes, and snippets.

@KDawg
Created October 31, 2012 15:52
Show Gist options
  • Save KDawg/3987838 to your computer and use it in GitHub Desktop.
Save KDawg/3987838 to your computer and use it in GitHub Desktop.
iPhone Web Browser Remote Debug from Desktop

Remote debugging USB-connected iOS6 via Safari

Of course at the end of app development it's bug season. Testing on device is a big deal with some of these problems because they only happen on the resource-restricted device. Testing on device is everything when it's a mobile-specific web app.

In the past we've used various add in tools but with iOS6 it's all built in. Here are some notes helping remote debug from desktop to usb connected phone.

Safari Upgrade and OS X Versions

Safari 6 comes with "Mountain Lion" 10.5, but I'm on "Lion" 10.4 and the Safari upgrade doesn't appear to be automatic – you know how Apple likes to force upgrades. Easily worked-around, however, as Safari6 is hosted on Cnet here: http://download.cnet.com/Apple-Safari/3000-2356_4-34119.html

Setup on the phone:

  • iPhone must have iOS6 on it.
  • System desktop/menu
  • Settings -> Safari
  • Scroll down to "Advanced"
  • Click "Web Inspector" to "on"
  • Bust out mobile Safari and load your web page
  • USB connect to your MBP

##Setup on the desktop:

  • Desktop must have Safari6 running.
  • Launch Safari6
  • "Develop" pull down menu
  • "My Dev iPhone" option lists my attached device
  • It's sub-menu lists the pages open on the phone to attach to
  • Debug and have success!

Poke around with the Safari desktop interface

Of course the best way to learn is doing. Poke around with the Safari desktop tool finding out what it can do with the USB-connected iPhone. At the very least look for these features:

  • Inspect the DOM and element attributes and properties
  • Read source code setting break-points to inspect variables and stack-traces
  • Watch XHR requests and responses for service-side REST calls
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment