Kevin Whinnery
Debugging Titanium Applications

Titanium PR3 was just released, so to help showcase the desktop goodness I am porting Yahoo!’s Sideline desktop application (currently implemented for Adobe AIR) to Titanium. During that process I have learned a few things about debugging in Titanium, so I thought I would share those now.

Titanium is built using Webkit, which contains the very useful Web Inspector for debugging your Applications. To bring up the Web Inspector in your TI app, press the command + alt + c keyboard combination and you will be presented with the Web Inspector and all the JavaScript debugging goodness thereto pertaining.

But sometimes you have some logic in a document ready event handler, like so:

$(function() {
  //do something on load
});


Which you can’t debug in the web inspector right away, since when you make a change in your TI application, you can’t just ‘refresh the page’, you have to actually restart the app. To work around this, use setTimeout to give you enough time to launch your app and bring up the web inspector before that onload logic is executed:

$(function() {
  setTimeout(function() {
  //do something on load
  }, 15000); //This gives you 15 seconds to hit command+alt+c
});


Just a simple tip that I thought I’d file away for later. Hope that helps, and check out Titanium when you get a chance.

blog comments powered by Disqus