views:

133

answers:

2

From the question "How Does Appcelerator Titanium Mobile Work?" I know that the JS is cross-compiled into native code. But where does this happen? I couldn't find any code for this in the open source Titanium code. The website of Appcelerator also is quite sparse on the cross-compilation part of the process.

A: 

I believe Titanium Developer compiles this during the build process. If you look in your Project/build/android or Project/build/iphone directories you will see the code output.

In Titanium Mobile 1.3 they introduced XCode project generation, so you can now open the project using XCode.

Ben Bahrenburg
+1  A: 

In Titanium 1.4 on Windows/Android look in C:\ProgramData\Titanium\mobilesdk\win32\1.4.0\android\compiler.py and you will find:

def compile_into_bytecode(self,paths):
    jar_path = os.path.join(self.template_dir,"js.jar")
    for package in paths:
        args = [self.java,"-cp",jar_path,"org.mozilla.javascript.tools.jsc.Main","-opt","9","-nosource","-package",package,"-d",self.classes_dir]
        count = 0
        for path in paths[package]:
            # skip any JS found inside HTML <script>
            if path in self.html_scripts: continue
            args.append(path)
            count+=1
            self.compiled_files.append(path)
        if count > 0: run.run(args)