
A few years ago, I got to write my first mobile app using Objective-C and XCode. It was an incredibly simple app for the best Pitchman in the land, Billy Mays. The one thing I remember was the learning curve. To effectively develop for iOS, you need to understand a vast ecosystem of technologies and concepts that involved more than just Objective-C, Cocoa Touch, and XCode.
The concepts are still important, and you’ll learn them later, but they can certainly be intimidating when you just want to get started with a simple (or as complex as you want) app.
All I wanted to do was write a simple app to enable people to outfit themselves with the legendary beard and blue shirt, so that they might feel an ounce of his awesomeness. It took me 3 months of hacking away at night in my free time…thats like a year in internet time.
Now, I don’t want this to sound like I am or was afraid to learn something new, or that the iOS platform is impossible or not developer-friendly. In fact, I tend to sink my teeth into anything new and exciting, and I still think there are many scenarios where it makes sense to go with platform-specific languages and frameworks. The rub was that just that to get the simplest of apps up and running was like climbing Everest just to see if you like snow…there might just be easier and more efficient ways to do it.
For a few years, I hacked away with Objective-C and never really fell in love with it. Then Titanium from Appcelerator came along…
Titanium empowers developers to write native* applications for iOS and Android using the language so many of us know and love (to hate on), Javascript. Titanium gave me the tools to write less code and create apps in days and weeks…not months.
At Bunchball, we recently had a 24-hour hackathon to combine our Nitro Gamification Platform with another 3rd party API. In around 18 hours, I had a completed application that did the following:
Being able to rapidly create a prototype like this was an incredible experience, it spoke to the power of Titanium, and it even won me a trip to SXSW (again, I love this company).
While Titanium is relatively easy to start with, there are a lot of new terms, concepts and idioms that are unique to the two large mobile platforms as well as the Titanium APIs. That’s why this is going to be a multi-part installment :)
Ok, that’s enough jibba-jabba…let’s dive in and cover the basics of getting started with Titanium…
I won’t spend time here re-writing what can be Googled. After all, learning how to find information yourself is important! But, here are some handy links…
Titanium’s raw API documentation isn’t the best I’ve seen…but I’ve seen worse. That said, it’s a great place to know exactly what tools you have at your disposal. You can view the raw API documentation here.
While the API documentation isn’t always the most complete, Appcelerator really does go out of the way to produce some really top-notch training videos and tutorials to get you going. For true beginners, the Zero-To-App videos are indispensable and a logical starting point. Within about a half hour, you should have a really good grasp of the Titanium environment. If you’re ready to go deeper, the Building Native Mobile Applications videos are incredibly in-depth and will open many doors for you on your journey through Titanium. I’ve been using Titanium for some time now, and I still find these videos to be a helpful refresher.
Another really great way to learn some of the basics of Titanium is to download the “Kitchen Sink” App. As with anything, it’s always fun to just be able to tinker with someone else’s code and see what you can break. The Kitchen Sink App is essentially an App with about 95% of the available Titanium APIs demonstrated. You can simply import the project into Titanium and run it in the simulator of your choice.
Again, for the sake of getting into a few of the basics of a Titanium App, I won’t go into extensive detail as to how to import a project. (You basically create a new project from an existing source…I’m confident you can figure that out)…or, you can click here to watch a video detailing importing a project.
One important note about the Kitchen Sink, however: the structure of the code sucks. Terribly. One lesson I learned early on was how much your life will suck if you structure your Titanium projects like the Kitchen Sink example. It’s not DRY, it pollutes the global scope like a coal factory of code, it essentially has one file-per-screen and well, it’s just a shining example of how NOT to structure your project.

When you create a new Titanium project, you’ll be greeted with the structure to the left. Some of the more pertinent items are:
tiapp.xml - Your application’s primary configuration file. It contains everything from deployment targets to supported orientations to the copyright and description of your app. This file is important to get to know, but you won’t spend a bunch of time in it once you have stuff configured.
build - this folder is where any projects you build will end up, whether on the simulator or to your device.
Resources - This is where you will spend most of your time. The resources directory contains the Javascript files that will run your application, directories and sub-directories of images, as well as any other supporting files your application may need.
Resources/App.js - The bootstrap file for your application. When your app launches, whatever is in this file will be executed. Generally, you want to leave as much code as possible out of this file, and instead include the files that kick off your application in here. Good Titanium projects are usually setup with an MVC architecture in mind, so think of App.js as the “front controller.”
Resources/android & Resources/iphone - These folders are where platform-specific icons go. You can go nuts creating subdirectories inside of here (I usually create an “images” directory at minimum inside here). If you create an image view in your project, you don’t need to include the full path. You can just use a path such as ”../images/myImage.png,” and Titanium will automatically pull the image from the folder corresponding to your platform. By default, inside each of these folders, you will see a few images when you create a new project:
Launching the app is drop-dead simple. When you first create your project, you’ll notice that app.js has code that sets a background color, creates a tab group, and creates a few windows. An app doesn’t get any simpler.
To run the app, select the project in the Project Explorer on the left, and then click on the little play button above it. Choose “iPhone Simulator” or “Android Simulator”…give it a few seconds, and your first (albeit simple) app should launch!

As you look at the code that is initially placed in app.js when you create a new project, you can see a few of the basics of a Titanium app in the flesh. Really, at the heart of any Titanium app large or small live a few basic concepts and core elements. Here’s a few to get us started on our journey…
As we’ve seen, there are a few steps to get up and running with Titanium, but really, most of the configuration is now behind us. From here on out, we’re free to play with the framework and really start having some fun. In later installments, we’ll go through structuring a large application, some basic Javascript best practices, and some advanced topics like memory profiling with Instruments (for iOS apps).
Titanium is a very powerful engine for creating near-native* apps that look great and run on several platforms with minimal effort. Take advantages of the vast resources available, and start to dig into mobile development with Titanium. Maybe you’ll write the next Angry Birds…
Titanium isn’t “Write once, run everywhere,” or as some would say, “Write once, suck everywhere.” Titanium wants you to embrace the platforms you are targeting, and the unique experience that each platform’s users expect. Think of Titanium as “Write once, adapt everywhere.” Nearly all of the code you write is cross-platform (Android and iOS), but there may be some times where you need to conditionally show one thing on one platform, and a different experience on another…we’ll dive into that later.
Also, your Javascript isn’t transformed into Objective-C or Java, as some would believe. The Titanium framework has a series of proxies that essentially act as a bridge between the OS of choice and your Javascript code. The performance hit is negligible, but is a factor in some instances. If you want to learn more, check this out…
results were amazing. Kasey McCurdy, superstar Bunchball front-end engineer, built...18...