Debugging Websites for iPhone
I created a website that looked great in IE7+, FF, Chrome, and Safari, but on the iPhone a few things looked off. Problems could be from the viewport being 480px wide but the website is 1000px wide so using percentages can mess it up… that’s another post sorry. The problem is, how do I use something like firebug to debug the css and html in the iPhone mobile Safari browser?
The best solution is if you have a Mac OS X and the iOS 5 SDK. If you don’t have a Mac or you don’t have iOS5 SDK and don’t want to download it from the Mac App Store, move on to the next solution. This solution involves a great FREE tool to debug, profile, and inspect web applications running in the iPhone simulator is iWebInspector by Max Firtman. This tool, as it says in the tool, enables a private API available on the iOS 5 framework. It lets you inspect the web page or webapp similar to firefox. To use it:
- Download, install, and open iWebInspector
- Click on the “Open iOS Simulator” button
- In the Simulator, open Safari and go to the URL you wish to debug.
- In iWebInspector click on the “Load from Safari” button.
- Click on the link it displays
- Now you should see the DOM and all it’s CSS attributes.
One thing annoying is that you can’t add CSS attributes to existing CSS classes. A way around this is to add attributes to the element.style section for the element you want to alter. Another thing I noticed is that the Simulator freezes from time to time. To “unfreeze” it I had to quit both the simulator and iWebInspector and start over. Other that it’s great!
A second option to debug a website in the iPhone is by using Firebug Lite. Here’s what you do:
- Open this page in your iPhone browser and bookmark it.
- Rename the bookmark to “Firebug”.
- Tap the code below twice and choose “Select All” and then “Copy”.
- Edit the Firebug bookmark. Remove the URL and paste the copied code into the bookmark.
- Save it.
- Go to the page you want to debug
- Once the page loads, select the bookmark named “Firebug” and it will run firebug on the page.
I prefer the first solution over this one because obviously, Firebug is very small on the iPhone.
keywords: iphone safari on desktop, iphone firebug