Titanium Hack: FastDev for iOS

Testing large Titanium Mobile applications on iOS devices can be cumbersome, since the build & deploy process can take several minutes, even when the project is launched directly from XCode. Repeating the same process each time, for checking the effect of small modifications to the code is then quite annoying and time consuming.

I just posted a small project on github at https://github.com/omorandi/TiiOSFastDev that aims at solving this issue.

It is a quite hackish solution that allows you to change on the fly the application resource files of your project and get them pulled by your app (either on device or simulator) without needing to rebuild it, sign it, and re-deploy it.

The solution consists in a bunch of scripts that perform these operations:

  1.  patch your Titanium SDK folder (or, better, a copy of it)

  2. start an HTTP server in the Resources directory of your Titanium Mobile project

Once these steps are completed, you can build your app and deploy it to the device for testing. Should you find you need to fix some of your program files, just do it, manually restart the app, and proceed with testing, without needing to rebuild & redeploy it.

This process is similar to the one involved using the fastdev feature for Android, however the mechanism is not managed by Titanium Studio, and involves a series of steps to be performed manually.

The Ti SDK patching script expects you to work with a 1.8.X Titanium Mobile SDK. It can be modified in order to work with 1.7.X versions, however this is not currently supported.

The http server is implemented as a simple node js script, so for executing it you need a working node environment in your system (you can grab it from http://nodejs.org/ ).

How to use it

First, check out the TiiOSFastDev repository  from github.

In the following steps I use the following symbols for the involved directories:

$TI_FASTDEV_DIR (the directory containing this repository)

$TI_SDK_DIR (usually /Library/Application\ Support/Titanium)

$PRJ_DIR (The root directory of your Ti Mobile App project)

  1. Check out your Titanium Mobile directory under $TI_SDK_DIR. There you’ll find one or more directories of the SDKs installed in your system.

  2. Create a copy of the SDK directory you want to patch and call it for example 1.8.0-fastdev (actually you’ll want to keep the original SDK directory intact for the normal development workflow)

  3. In a terminal window, go to the directory that contains the files of this repository ($TI_FASTDEV_DIR) and perform the following:

    ./patch.sh 1.8.0-fastdev

  4. Launch your Ti Mobile application from Titanium Studio or through your preferred method. This is needed in order to re-create the build/iphone directory in your project, with the patched files. If this doesn’t happen, just clean the project and relaunch it

  5. For your convenience, create an alias for the startserver.pyscript:

    alias fdstart='$TI_FASTDEV_DIR/startserver.py'

  6. Then cd in the Resources directory of your Titanium Mobile application project, for example:

    cd $PRJ_DIR/Resources

  7. Using the previously created alias, you can start the server with:


  8. That’s it, you can now restart the application from Ti Studio (if you want to use the simulator), deploy it on the device, or, better, build the app for device in XCode (by opening the XCode project you find in $PRJ_DIR/build/iphone, sign the product and install it on device. From now on your application JS files are pulled through the server you started in the Resources directory of your project.

  9. Enjoy the time you have saved with this hack ;-)

Demo video

I made a demo for showing how this hack can be used. Please note that when launching the project from XCode I select the Simulator target only for convenience (it’s not that easy to show the iphone screen output in a screencast):

Titanium Mobile iOS FastDev hack demo from Olivier Morandi on Vimeo.