Solved

Javascript errors in Ionic app deployed on ios

Posted on 2016-08-07
3
53 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 54

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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Shopping Cart 2 73
Passport Expiry 3 44
specific navigation button disappears on mobile devices 1 15
Jquery-Javascript setAttribute function help 7 10
Introduction JSON is an acronym for JavaScript Object Notation.  It is a text-string data transport mechanism, capable of representing simple or complex data structures in a consistent and easy-to-read manner.  Similar in concept to XML, but more e…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
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)
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

810 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