CDVDebugView removed from Apache Cordova in version 2.2.0, resides here now
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Cordova JavaScript Exception Logging

CDVDebugView was removed from Apache Cordova in version 2.2.0, and resides here now. In Cordova, adding a few files to your project will enable you to effectively log JavaScript errors to your console at a lower level, without using JavaScript code (window.onerror, console.log).

With iOS 6, you are better served by debugging your code using Safari 6 and the iOS 6 Simulator.

NOTE: when you include these files, it will always pop up a warning dialog at startup, to remind you that you have these classes included. This is to prevent you from inadvertently shipping this code for the App Store, where this code is not allowed (it uses a private interface).

  1. Install Cordova

  2. In your app, add the CDVDebugWebView.h, CDVDebugWebView.m and WebScriptDebugDelegate.h files to your project. Make sure you select the radiobutton - "Create groups for any added folders"

  3. In your app's MainViewController.m, uncomment/add this code:

     - (CDVCordovaView*) newCordovaViewWithFrame:(CGRect)bounds
         return [[CDVDebugWebView alloc] initWithFrame:bounds];
  4. Don't forget to add the import at the top of your MainViewController.m file as well:

     #import "CDVDebugWebView.h"
  5. For newer versions, you may also need to add -fno-objc-arc to CDVDebugWebView.m build flags (in xcode, select the CordovaLib project, CordovaLib target, build phases tab, compile sources list, find CDVDebugWebView.m and add the flag).