Maybe you have already tried Appcelerator’s Titanium. If not, you should have. It’s a very easy to use RAD framework for creating cross-platform desktop and mobile applications based on HTML, Javascript, PHP, Python and Ruby. However, I was having a grave issue lately with their desktop builds. No matter what, I could not build the Windows installation package of my applications. Appcelerator’s documentation on manually packaging applications is sketchy and outdated. So I did what any self-respecting hacker (in the good sense, i.e. geeky developer with a strong aspiration to solving complex problems) would. I figured out a solution myself and documented everything in the process.

First things first, we have to install some prerequisites to “prime” our environment for building installation packages of our Titanium applications. Sadly, Appcelerator’s documentation doesn’t mention much and is, of course, terribly outdated. To save you from trouble, I figured it all myself and present it to you right here.

SDK installation and setup

Before you begin, install Titanium Developer, launch it and install the desktop SDK. Do note that the first time you run it, it will prompt you to install the Mobile SDK. Do it. Then shut down the application, launch it again and it will prompt you to install the desktop SDK. Do it and shut down the application. Counter-intuitive it is, but it works…

You will also need to put Titanium’s SDK directory in the path. Once more, the documentation is just plain wrong and gives you an inexistent path. Anyway, Titanium SDK is ultimately installed in c:ProgramDataTitaniumsdkwin32VERSION, where VERSION is the Desktop API version. At the time of this writing the latest API was 1.1.0, so the path we need is c:ProgramDataTitaniumsdkwin321.1.0.

In order to add that to the path, hit the Windows key + pause, click on Advanced system settings from the left bar, click on the Environment variables button, double click on path, append ";c:ProgramDataTitaniumsdkwin321.1.0" without the quotes of course.

Finally, we need to put the directory of Titanium’s copy of ImageMagick to our path. In order to add that to the path, hit the Windows key + pause, click on Advanced system settings from the left bar, click on the Environment variables button, double click on path, append “;c:ProgramDataTitaniumsdkwin321.1.0magick” without the quotes of course.

Third party software required

Next up, let’s install the third party software we need. Unfortunately, the Appcelerator documentation doesn't mention any of it and it's all left to the imagination of the developer. Let me save you from the trouble of figuring out what and how you have to install.

The very first prerequisite is installing Python 2.6 from from http://www.python.org/download/releases/ (tested with 2.6.6). Next, let’s put Python in your path. Hit the Windows key + pause, click on Advanced system settings from the left bar, click on the Environment variables button, double click on path, append “;c:Python26” without the quotes of course.

You will also need to install WiX from http://wix.sourceforge.net/downloadv3.html. This is required for Titanium to be able to build the installer executable file of your application. Download and install the regular MSI package, NOT the 64-bits one even if you have a 64-bit version of Windows. Remember that all Titanium apps run in 32-bits mode and need a 32-bit installer. During installation, ignore any warnings about missing Visual Studio.

Building your application

The good news is that you can build your Titanium application’s installer manually. The bad news is that you have to use the command line to do that. If you are afraid to use the command line (CMD.exe) or have no idea about DOS commands, tough luck. Otherwise, you can read on.

Very important note: Your application version number must be in the x.y.z.w format, where x, y, z and w are integers. For instance, you can’t use a version number like 1.0.a1 or your packaging job will simply fail.

I will assume that you are building an application named MyApp placed on your desktop in a directory named MyApp. If no such directory exists already, create the directory win32 inside the dist folder placed by Titanium Developer inside the MyApp directory.

Open a command prompt. Just hit Windows key + R, type in “cmd” without the quotes and hit the enter key on your keyboard. You are presented with the black command prompt window. Type in the following command:

python "c:ProgramDataTitaniumsdkwin321.1.0tibuild.py" -v -o win32 -t network -s "c:ProgramDataTitanium" -a "c:ProgramDataTitaniumsdkwin321.1.0" -d "MyAppdistwin32" -p test.exe "MyApp"

You may notice something strange, the test.exe parameter. For the life of me, I don’t know why this is required. No idea, really. It is not used anywhere, but it just seems that if it is not specified the packaging will fail with a cryptic message about the wrong drive being specified!

If you did everything as I described, you now have a MyApp.exe installation package in MyAppdistwin32. You can distribute that to your users.

The sexy stuff: customizing the installer

As you may have noticed, the installer’s stock artwork has a strong reference to Appcelerator’s Titanium brand. If you want to customize the installer’s header, all you have to do is replace C:ProgramDataTitaniumsdkwin321.1.0default_banner.bmp with one of your liking.

No comments