34

So iOS6 is out, horrah. Now, it appears as though Apple have removed the 'Developer Console' that used to exist in Safari. Great, I hear a lot of people say - it was limited.

But, it works on the device - now apparently you have to connect the device to a Mac to get web inspector?

Is this the only way of debugging with console? Is there a way of debugging with windows, safari? Please note, I don't mean just changing user-agent, which you can do on Safari Windows - that doesn't register touch events - just click.

pnuts
  • 58,317
  • 11
  • 87
  • 139
waxical
  • 3,826
  • 8
  • 45
  • 69
  • 2
    The debug console on the iPad was indeed limted to only `console.log()` lines, but it was easy to use and fast. I have also upgraded one of my iPad's to iOS6 and tried to hook it up on Safari (Windows), but Safari developer menu isn't even showing the iPad. I tried to install iTunes (hate that program :( ) but even then no luck. – Sven van Zoelen Sep 28 '12 at 14:37
  • 5
    Hooked it up on my MacBook Pro and voilà, it worked... Also tried to reinstall safari with the latest version, but still no luck on Windows 7. Apple is really starting to irritate me with their boycotts and forcing users to use particular software attitute. – Sven van Zoelen Sep 28 '12 at 14:57
  • 26
    Holy crap, Apple what the hell. I'm not mad that they didn't support windows with the new version, I'm mad that they completely removed the debugging console on the IPhone! Now besides buying a Mac, there's absolutely ZERO ways for me to debug. Isn't this violating some anti-competitive law or something? What are windows users supposed to use javascript `alerts` to debug? – K2xL Oct 02 '12 at 15:20
  • See also [Accessing iOS Safari Web Inspector from Windows Machine](http://stackoverflow.com/questions/12556895/accessing-ios-safari-web-inspector-from-windows-machine). –  Aug 12 '13 at 17:40

8 Answers8

7

If you don't have Mac OSX you can use this script as console replacement:

https://github.com/robotnic/waterbug

It shows error message, it's possible to log all kind of variables, you have to turn your iPhone or iPad 90° to the right to open the console.

Ali Shakiba
  • 20,549
  • 18
  • 61
  • 88
bernard
  • 306
  • 1
  • 8
5

A poor mans debugging console:

    try {
        var test = document.do.something();
    }
    catch (exc) {
        alert(exc);
    }
Davy
  • 6,295
  • 5
  • 27
  • 38
  • The iOS SDK does not have Try...Catch and you should use a code example that wouldn't come across possibly offensive. – AxGryndr Sep 26 '13 at 18:44
  • 2
    Im not sure what you mean by "the IOS sdk does not have try catch"? This is standard javascript and im quite sure that this simply works on the ipad (will retest to verify) – Davy Oct 02 '13 at 08:30
  • it does work, the only thing here is that with such debug thing developer will need to go line by line what exactly JS file and what exactly method caused specific exception ... – Anonymous Jun 24 '14 at 14:43
4

One can debug on the device by using bookmarklets (especially within Mobile Safari).

Debugging on the device can be very important if an error only appears live on the device but nowhere else. There is a variety of bookmarklets for developer, so choose the tool of your choice (e.g. Firebug Lite), add it to your bookmarks and use it right where you need it. This may not be the Developer Console, but it is a method to debug much more accurate and job-oriented.

I wrote a blogpost on how to use bookmarklets on my weblog (there is also a list of other common testing tools and further bookmarklets):

UPDATE: Chrome released its Mobile DevTools which will make debugging (within Google Chome Mobile, Android Devices only) much easier. This will not fix the missing DevTools issue within Safari, but it might help to locate errors on a device:

UPDATE2: Mozilla released a Firefox add-on to enable web development across browsers and devices: http://youtu.be/kEFbQwB81RE?t=1m58s

Sven
  • 1,450
  • 3
  • 33
  • 58
  • 1
    That last link you've provided is only for android devices and cannot be used with iOS. – vsync May 20 '14 at 15:09
  • @vsync Damn, you're right! Thank you very much for pointing it out, I added it to my answer :) – Sven May 20 '14 at 22:31
  • Unfortunately, it seems the Mozilla add-on for Firefox is no longer maintained. – Jimmy Sep 27 '21 at 05:11
3

Have a look for weinre. It allows you to inspect a page running in Safari from another computer using a Chrome-like web inspector

tarling
  • 1,887
  • 2
  • 19
  • 27
2

You can use window.onerror to debug errors without a console. Simply add this code to your HTML document in its own <script> tag before any other Javascript code:

<script type="text/javascript">
    window.onerror = function(e){
        alert(e);
    };
</script>

This will do so that whenever there is an error, the error message will be shown in an alert dialog box, which is visible in iOS Safari. It's important that the above code runs before the error you're trying to debug, and if you're debugging a syntax error, it's also important that it's in a separate <script> tag.

Donald Duck
  • 8,409
  • 22
  • 75
  • 99
0

Looks like the built in console is gone. I tried plugging into a Windows 7 and opened Safari and could not locate the developer console. Then I read this article which confirmed it.

If you need to be able to test your site in both orientations then waterbug is not a good option, because it uses up the landscape orientation for its console view.

One decent option is to use Adobe Edge Inspect. You open your site on Chrome and open the app on your device and your device will mirror whatever page you have open on your desktop. Then you can use the Chrome dev tools to debug your content.

djvg
  • 11,722
  • 5
  • 72
  • 103
Tim Kindberg
  • 3,605
  • 1
  • 25
  • 26
0

Instead of Safari on Windows you could use an app by Telerik called AppBuilder. I've found the instructions on this blog. You'll need to get an account to use the Telerik Platform though.

This will give you dev tools like the ones in Safari. I've used it on Win7 64 bit with regular web apps and Phonegap apps running on an iPad with iOS 7.1.

neno
  • 61
  • 3
0

Like neno suggested, Telerik AppBuilder is a great applications. I am actually running Windows XP in a virtual machine on Linux only for the purpose of debugging my iPhone. Windows XP because in my case Windows 7 does regognize the iPhone, but iTunes and Telerik AppBuilder don't.

haffla
  • 1,056
  • 8
  • 15