Solved

Javascript errors in Ionic app deployed on ios

Posted on 2016-08-07
3
62 Views
Last Modified: 2016-09-20
I am working on an Ionic app. When testing in the browser (on laptop), Chrome developer tools provide a great way to debug using console.log. It also shows Javascript errors in the browser console.

However, once the app is deployed on iPad (using xcode) the browser console is no longer visible. How can I see the statements printed using console.log and Javascript errors, if any.

Some actions in my Ionic app are not responding after the app is deployed on iPad. I think there might be some Javascript errors being thrown but I am not able to find what they are.
0
Comment
Question by:ank5
3 Comments
 
LVL 55

Assisted Solution

by:Julian Hansen
Julian Hansen earned 250 total points
ID: 41746822
The following might be of use

Firebug lite for Mobile you can find it here

https://getfirebug.com/firebuglite_mobile

Waterbug for Safari - you can get it on GitHub here

https://github.com/robotnic/waterbug

Another option is to build a debug window in your app that is activated by some internal state variable. I usually have a pull down pane that appears as a handle in the top right of the screen. Anything I want to see going on either on the server or in the console I log to that window using JavaScript. The presence of the handle is activated by a URL parameter or a server side variable.

You redefine your console.log function to send to a div like so
if (typeof console  != "undefined") {
  if (typeof console.log != 'undefined') {
  console.clog = console.log;
  }
  else {
  console.clog = function() {};
  }
}

console.log = function(d) {
  console.clog(d);
  $('#debug-pane ul').append($('<li/>').html(d).addClass('list-group-item'));
};
  
//console.error = console.debug = console.info =  console.log;

window.onerror = function(message, url, linenumber) {
  console.log("JavaScript error: " + message + " on line " +
    linenumber + " for " + url);
}

Open in new window


Here is a working sample demonstrating the concept.
0
 
LVL 1

Accepted Solution

by:
ank5 earned 250 total points
ID: 41747608
Below post solved the problem -

http://phonegap-tips.com/articles/debugging-ios-phonegap-apps-with-safaris-web-inspector.html

I am now able to view console logs and Javascript errors in Safari console
0

Featured Post

How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
Learn about the eCommerce marketing trends for the year ahead.
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

808 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question