?
Solved

Javascript errors in Ionic app deployed on ios

Posted on 2016-08-07
3
Medium Priority
?
70 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 58

Assisted Solution

by:Julian Hansen
Julian Hansen earned 1000 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 1000 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

Cloud Training Guides

FREE GUIDES: In-depth and hand-crafted Linux, AWS, OpenStack, DevOps, Azure, and Cloud training guides created by Linux Academy instructors and the community.

Question has a verified solution.

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

Some of the SEO trends we might expect in 2017.
Mobile app development companies have absolutely changed the ways apps are being browsed, used and downloaded by users today.
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.

764 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