Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a way to debug JavaScript in the iPhone/iOS Safari browser?

I have a strange behavior on the iPhone browser. Is there a tool to debug the JavaScript of the iPhone browser?

I'm hoping there's something more advanced than simple alert() messages. Is there something with advanced tools like setting breakpoints and viewing object states?

like image 909
gmadar Avatar asked Aug 30 '11 12:08

gmadar


People also ask

How do I use developer tools in Safari iOS?

From the Safari menu bar, select Develop and choose the name of your attached iOS device, then select the URL that appears under Safari to open the debug console for that site. After you connect your device, use your Mac to inspect the website you want to debug and have it open in the Safari mobile browser.

How do I debug JavaScript on iPad Safari?

To debug JavaScript on the iPad, you need to open the Safari browser. Use a USB cable to connect the iPad to Mac. Safari opens and your iPad now visible in the DEVELOP Menu. After selecting, start debugging JavaScript.

Does iPhone Safari have JavaScript?

You can enable JavaScript on your iPhone in the Safari section of the Settings app. If JavaScript isn't turned on, many websites will appear broken in your Safari browser. Though JavaScript should be enabled by default, it's important to check that it hasn't been accidentally disabled.


1 Answers

With the release of iOS 6, Apple released Remote Web Inspector for their Mobile Safari, and this is huge. Basically you have all the features and power of Web Inspector in regular Safari, for your mobile apps, including Phonegap apps.

I've used weinre but this tool makes it obsolete for newer versions of iOS (unfortunately not for old versions of iOS, non-iOS devices, or if you're on Windows) since its a full-featured debugger with breakpoints and everything.

Requirements:

  1. A Mac with Safari 6+
  2. Either a USB-attached iOS 6+ device or xCode 4.5+ running an iOS 6+ simulator

How to activate the inspector:

  1. In your simulator or device, open Settings > Safari > Advanced > Web Inspector > On
    (this is on by default in the simulator)
  2. In Safari 6+ for Mac, access your page from the Develop menu. You can enable Develop menu in Safari's Advanced Preferences if its not showing up.

    Safari Web Inspector

    enter image description here

More discussion at the bottom of:
http://www.mobilexweb.com/blog/iphone-5-ios-6-html5-developers

(Also, if you read about a "secret private interface" or iWebInspector somewhere, these are also made obsolete.)

like image 77
B Robster Avatar answered Sep 22 '22 18:09

B Robster