Building and debugging websites and web applications for mobile devices can be a hassle. On the desktop we have powerful debugging tools; most browsers have a web inspector of some kind. But we don’t have those tools for devices like the iPhone and iPad … that is, until now!
With the recent release of Safari 6 and iOS 6, you can now use web inspector to build and debug websites on the desktop and on mobile Safari. Best of all? It’s a simple process to setup. Follow this tutorial and you’ll have some powerful debugging tools for mobile iDevices at your fingertips in no time.
Modern browser developer tools have been an immense help in building websites and web applications. Chrome has developer tools. Firefox? Firebug. Safari? Web inspector. All extremely powerful tools in web development.
Be that as it may, up to this point debugging websites and web applications on mobile devices has been a hassle. As Safari and Chrome both run on the webkit engine, there are many similarities in the way the desktop and mobile browser render a web layout. Thus, most designers/developers build and tweak their websites on the desktop using one of these browers, assuming the similarities resulting from the webkit engine will render the page equally the same on a mobile device.
However, mobile and desktop platforms are acutally quite different. They have different memory capacities, performance potential, input devices, and network connectivity. So it has become imperative that a designer’s debugging tools for mobile devices become more performant and match those of their desktop counterparts.
Apple’s new software releases of iOS 6 and Safari 6 bring many of the features of desktop browser debugging tools we all know and love to mobile devices. This tutorial will show you the simple process of getting setup to debug mobile websites using Safari’s web inspector.
Before we start, a note on compatibility: There’s a bit of bad news for those using Windows. You can only debug using the remote web inspector on a Mac. Safari 6 for windows is not available. Also, Safari 6 is only available for Macs running OSX Lion or higher.
There are two methods for using web inspector in mobile Safari:
We’ll cover both of these methods and let you choose which one suits your situation best.
Because debugging mobile devices with web inspector is a new feature, you’ll have to make sure you have all the latest software.
Real Device Method: To use web inspector in tandem with a real iDevice, you’ll need the following:
Virtual Device Method: To use web inspector in tandem with iOS simulator, you’ll need the following:
Checking Software versions: To check if you’re running iOS 6 on your iDevice, go to “Settings > General > About” on your device.
To check if you’re running Safari 6 go to Safari’s menubar and click “Safari > About Safari”.
To ensure you’re running Lion, click on the Apple logo in the menu bar and choose “About this Mac”
To ensure you’re running the correct version of Xcode, open Xcode and choose “Xcode > About Xcode”
You must enable the developer tools and web inspector in the desktop and mobile versions of Safari.
Real Device Method: If you’re going to use a real device, connect it to your mac via USB.
Virtual Device Method: If you’re going to use iOS simulator, open Xcode, then right-click on the dock icon and choose “Open Developer Tool > iOS Simulator”.
Mobile Safari: On your real iDevice or in iOS simulator go to “Settings > Safari > Advanced” and turn on “Web Inspector”.
Desktop Safari: If you don’t already, ensure you have developer tools in Safari turned on. You’ll know you have them turned on if you can see “Develop” in the menu bar.
If you can’t see “Develop” in the menu bar, go to the menu bar and click “Safari > Preferences > Advanced” and select the “Show develop menu in menu bar” checkbox.
Now that you have either iOS Simulator open or your iDevice connected to your mac via USB (or both!), you’re ready to start using web inspector on your website.
On your mac, open Safari and go to “Develop”. You should now see any iDevices (virtual or real) that you have connected and running with your mac. In the screenshot below, you’ll see I have two devices in the menu: one is the iOS simulator, the other is a real iPhone connected to my mac.
In order to actually begin inspecting a website, you have to have mobile Safari launched on the device and have one of the tabs open to the website. If you don’t have mobile Safari open, you’ll see a message stating “No Inspectable Applications”.
To begin inspecting, simply enter the URL of the page you want to inspect in mobile Safari and then choose that site from the “Develop” menu. You can begin inspecting sites on your real iDevice or from iOS simulator. When you select the page, you’ll see a blue overlay on the page, indicating which one you’ve selected.
By choosing a site, Safari’s web inspector will open up and allow you to begin inspecting your website. That’s it!
Now that you have Safari’s web inspector at your fingertips, you have much more control in building and debugging websites and web applications.
Here’s a sample of some things you can now do when debugging mobile sites:
You have the tools, go forth and build!