Subject: iPhone: How does this work exactly
I've been having discussions with team mates about Titanium. I'm really jazzed about the platform, but I need to answer some questions.
I was able to create a demo from start to finish in 1.5 hours. Really sweet. And Titanium created an iPhone SDK Project for me.
However, it was just a reference into a bunch of libraries.
SO my question is... what does Titanium do with the JS files when it builds the iPhone project? Please be as technical as you can.
Thanks.
2 Posted by Dave Merwin on 29 Dec, 2009 06:26 PM
One thing we'd like to do is start the prject with Titanium and then pass off the iPhone project that is generated at build to a dev team to tweak if need be in Obj-C. But it looks like Titanium is writing right to byte code. Is that true?
Support Staff 3 Posted by Nolan Wright on 29 Dec, 2009 07:04 PM
Titanium takes your JS code and places it into an Objective-C file at
compile time. The JS still executes at runtime and communicates with
our Objective-C API via a custom bridge.
Our platform is modular. We build out our functionality as modules,
and if you have experienced Objective-C developers, they can build
custom modules that can be used by JavaScript developers. We are
working to improve our module API in the upcoming 0.9 release to make
it much easier to extend our platform.
4 Posted by Dave Merwin on 29 Dec, 2009 07:09 PM
Thanks so much for your reply! So it's NOT writing to bytecode. I want to make sure I understand...
The JS is actually communicating with the Obj-C API via a bridge. What is that bridge then? Obj-C?
Support Staff 5 Posted by Nolan Wright on 29 Dec, 2009 07:12 PM
yes, currently, it's a lightweight XHR bridge between JS and Objective-
C.
we do not write bytecode.
6 Posted by Dave Merwin on 29 Dec, 2009 09:58 PM
So, the JavaScript sends a call VIA XHR to the Obj-C libraries. You use the iPhone libraries.
So when I use the Titanium API, I'm usung an XHR protocol to the iPhone SDK libraries for the supported UI API Libraries.
For example... I create a JS Table in Titanium with the API calls that are allowed. When the project is built, the XHR takes your API and tells it to plug into the proper iPhone SDK library. Is that close?
Support Staff 7 Posted by Nolan Wright on 30 Dec, 2009 12:23 AM
Yes, and we have our own Objective-C API that uses the iPhone SDK.
At runtime, your JS makes calls to our Objective-C API (which in turns
uses the iPhoneSDK). In the case of a table view, our JS call (via
the bridge) results in the construction of a true native table view.
does that help?
8 Posted by Dave Merwin on 30 Dec, 2009 12:27 AM
Thanks so much. That REALLY helps.
9 Posted by Swaroop Hegde on 20 Jan, 2010 10:34 AM
I was told (misinformed) that phonegap creates a JS bridge while Titanium writes bytecode. Thanks for clearing it out.