Solved

Javascript errors in Ionic app deployed on ios

Posted on 2016-08-07
3
39 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 51

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Using in-flight Wi-Fi when you travel? Business travelers beware! In-flight Wi-Fi networks could rip the door right off your digital privacy portal. That’s no joke either, as it might also provide a convenient entrance for bad threat actors.
This article discusses how to create an extensible mechanism for linked drop downs.
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…
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.

744 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now