Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Best way to debug Javascript on an iPhone app?

I'm doing some rough development on the iPhone. I'm writing a native iPhone app, which uses an UIWebView object to load web sites with javascript. I find very difficult to debug the javascript code on an iPhone. What are the methods/techniques available for this matter?

like image 810
Hectoret Avatar asked Jun 09 '09 12:06

Hectoret


People also ask

How do I debug JavaScript on iPhone?

Here's how: Open the iPhone Settings menu. On an iPhone with an early version of iOS, access the Debug Console through Settings > Safari > Developer > Debug Console. When Safari on the iPhone detects CSS, HTML, and JavaScript errors, details of each display in the debugger.

Is there a way to debug JavaScript?

But fortunately, all modern browsers have a built-in JavaScript debugger. Built-in debuggers can be turned on and off, forcing errors to be reported to the user. With a debugger, you can also set breakpoints (places where code execution can be stopped), and examine variables while the code is executing.


2 Answers

Since Safari on the iPhone is using webkit, you could use the debugger built into desktop Safari's web inspector. While there will probably be some quirks that are different between platforms, it will give you a pretty good idea of what's going on in the interpreter.

like image 60
pjbeardsley Avatar answered Nov 02 '22 22:11

pjbeardsley


If you have access to an Android phone, you can debug your application using desktop Chrome's full developer tools and a USB cable (very convenient).

That means the debugger, profiler, HTML inspector, etc, all running on your mobile phone, but accessed through chrome running on your laptop/desktop computer.

Android Chrome and iPhone Mobile Safari are usually more similar to each other than Desktop Safari is to Mobile Safari, the screen format will be similar, the layout similar, and you'll be able to try real touch events, etc.

https://developers.google.com/chrome/mobile/docs/debugging

It'll require Chrome, an Android device able to run the android Chrome app, and a USB cable.

You have to install and use the ADB console command, but once its working, you'll have the full chrome developer tools interface available for debugging mobile.

like image 24
Seth Avatar answered Nov 02 '22 23:11

Seth