4

I'm working with an iOS targeted app built using Titanium (with Alloy); I want to be able to turn off the Javascript code optimization within Titanium Studio, but cannot locate anything by Googling, nor searching SO. When Titanium compiles it produces optimized javascript files...which makes interactive debugging difficult because in many cases it combines several lines of clean, readable code into a single line... which makes stepping into the code with the debugger difficult.

For example: this...

if(Array.isArray(detailItemArray)){
    //term-item.detail-items
    for(var z=0;z<detailItemArray.length;z++){
        if(z===0){
            //first item in detail-item array gets a title pre-pended to it
            // title is optional
            if(_.isString(termItemArray[y].title)){
                htmlArray.push(html.termItem(termItemArray[y].title,html.processStyle(detailItemArray[z]['style'],detailItemArray[z]['detail'])));
            } else{
                htmlArray.push(html.processStyle(detailItemArray[z]['style'],detailItemArray[z]['detail']));
            }

        } else {
            //process style if available, then add to the array buffer
            htmlArray.push(html.processStyle(detailItemArray[z]['style'],detailItemArray[z]['detail'])); 
        }
    }

} else {
    //when detailArray is not an array (sometimes it is -- see if statement above)
    //the title is optional
    if(_.isString(termItemArray[y].title)){
        htmlArray.push(html.termItem(termItemArray[y].title,detailItemArray['detail']));
    } else {

        htmlArray.push(html.termItemNoTitle(html.processStyle(detailItemArray['style'],detailItemArray['detail'])));
    }
} 

turns into this...a single line...

 if (Array.isArray(detailItemArray)) for (var z = 0; detailItemArray.length > z; z++) 0 === z ? _.isString(termItemArray[y].title) ? htmlArray.push(html.termItem(termItemArray[y].title, html.processStyle(detailItemArray[z]["style"], detailItemArray[z]["detail"]))) : htmlArray.push(html.processStyle(detailItemArray[z]["style"], detailItemArray[z]["detail"])) : htmlArray.push(html.processStyle(detailItemArray[z]["style"], detailItemArray[z]["detail"])); else _.isString(termItemArray[y].title) ? htmlArray.push(html.termItem(termItemArray[y].title, detailItemArray["detail"])) : htmlArray.push(html.termItemNoTitle(html.processStyle(detailItemArray["style"], detailItemArray["detail"])));

using Titanium Studio v3.2.3.201404181442

Any ideas if there is a setting that can temporarily disable this behavior so interactive debugging is easier?

Thanks in advance. --Scott

EDIT: A suggestion from a co-worker was to sprinkle some log statements in the code (like right after the "for" statements; and sure enough this prevented the optimizer from in-lining the code. Not exactly how I wanted to go about it, but, at least got me moving forward. Would still like to find a way to turn down the JS optimizer level or off.

ScottG
  • 41
  • 4

1 Answers1

3

Try titanium build -p ios --skip-js-minify.

From titanium build --help:

Build Flags:
   --legacy           build using the old Python-based builder.py; deprecated
   --skip-js-minify   bypasses JavaScript minification; simulator builds are never minified; only
                      supported for Android and iOS  [default: false]
   -b, --build-only   only perform the build; if true, does not install or run the app
   -f, --force        force a full rebuild
daniula
  • 6,898
  • 4
  • 32
  • 49
  • Good thought; gave it a try... still optimized the code into a single line. :( Since my project is an Alloy project (forgot to mention that), I found a couple more settings that I could set in the alloy.jmk - event.alloyConfig.beautify=true & false, neither had the desired effect. – ScottG Jun 03 '14 at 19:46