After my last post, I had planned to write a series of how-to’s related to Titanium mobile app development. Alas, I’ve changed development modes again.
A brief history of my iPhone app development
I’m the first to admit that I was very late to the iPhone dev party. I bought a book at least a year ago and cracked it open. Then I realized it wasn’t going to be as easy as playing Lego Indiana Jones, so I took a little break.
When I got back to development, I decided to try out a couple of frameworks that I had been reading about online. The first was PhoneGap. It’s a cool framework that lets you build iPhone applications using Javascript, HTML and CSS. My first app was just a test — a few buttons, some pages and some basic animations. I was able to put it together very quickly and the result looked good in the iPhone simulator, but it was much too slow on my actual phone. I don’t think that’s necessarily a failure of PhoneGap — it’s simply that anything that’s running in the browser is slower than native code. And that’s what PhoneGap does. It wraps up your Javascript, HTML and CSS into a basic shell of an app and essentially lets mobile Safari do most of the work. That’s cool, but it just didn’t have the right feel, so I moved on.
The second framework I tried was Titanium. Titanium is similar to PhoneGap in the sense that the code is written in Javascript, HTML and CSS. It differs in how that code is ultimately converted to an iPhone app. In Titanium, the programming model mirrors the native (Objective C) model. The code is written in Javascript, but much of it is converted to Objective C and then compiled by Xcode. Some of the code is still passed on to mobile Safari, depending on how you set up your project and what types of views you use, but with Titanium, it is possible to create an app that uses native UIKit (the native iPhone) controls. So I built the app I described in my previous post. The app worked and it was snappy. All the buttons and animations worked as expected. Everything went well until I upgraded my phone to iOS 4.0 and updated XCode and the iPhone SDK.
After my upgrades, things just stopped working. Weird things … like my Edit button just stopped appearing on screen, though it was still appearing in the simulator. I upgraded Titanium and tried again, but had no luck.
What I’ve learned
First off, let me say that I think both PhoneGap and Titanium are very cool and that I really think having some options for developing iPhone apps is a worthy goal. I’ve learned that PhoneGap provides some native control options now. That would take care of my speed issues. Titanium is working for many developers, so clearly the problem is either in my code or my configuration.
However, what I learned was that the biggest portion of the learning curve for me was not so much the syntax of Objective C, but other things such as the development environment (Xcode and IB), the view and controller model of iPhone apps, and the massive amount of stuff in the iPhone SDK. It’s all a little overwhelming at first. Ironically, by using PhoneGap or Titanium, I wasn’t able to get completely away from all of these things.
The development environments
Titanium provides its own IDE of sorts. It’s a very simple interface. It definitely wins the overwhelming UI battle. PhoneGap doesn’t have an IDE. You use Xcode. No gain there. There’s always a learning curve for new software. Xcode and Interface Builder are no exceptions. Just dig in.
Development concepts
In my first job, I built TCP/IP applications in C on Sun and Cray machines. The first time I had to grok the fork/exec model and use signals to handle sockets, I thought my brain was going to explode. After that I took a job building a Windows application using Delphi 1. Handling memory paging to deal with the fact that our data was larger than the 16-bit systems would allow was the bane of my existence for a week or two. Next I converted that app to a ASP and COM+ application. That whole project was a constant nightmare of IUnknown that I’d rather forget. And the list goes on and on. After a while, and with a little perseverance all of those new concepts became old concepts as I understood them.
It’s the same with developing iPhone apps. Understanding views, windows, table views, navigation controllers, etc. is just about taking the time to dig in and learn. Ironically, to take advantage of the native controls in Titanium (and probably also in PhoneGap), you’ll have to learn the same concepts — just in a different language. In fact, by the time I finished my Titanium-based app, I had enough general concepts in my tool box that switching to native was surprisingly obvious. I just had to learn some new syntax.
Massive iPhone SDK
When iPhone SDK 4 released, Apple included this gem in the overview page: “a rich set of over 1500 new APIs”. Fifteen. Hundred. NEW. APIs. Yep, that means that there are a lot more than 1500 APIs in the SDK in general. Cool? Yes. Overwhelming? Definitely.
Here’s the thing, though. Using a framework like PhoneGap or Titanium limits your exposure to all those APIs. Is that good or bad? It’s good if you only need the APIs that are exposed. It’s bad if you need even one that’s not. I didn’t do a thorough review of which elements of the SDK are available under each framework, but most of the standard stuff is available: camera, gps, vibrate, sound, contacts, etc.
So the answer on this one is that you don’t have to learn as much stuff in PhoneGap or Titanium, but if your app needs something that’s not supported by the framework, you’re either going to have to build it into the framework (Titanium provides some instructions for this — not sure if PhoneGap allows it) or you’re going to switch to native. Either way, you’re going to have to know the native SDK to get there.
Last thoughts
Learning Objective C (what of it I know) has been an interesting challenge. I hoped it would be like C or C++. It’s a little like C. Syntactically it’s not like C++, but having a handle on OO from C++ has helped. I bought a good Objective C book to go along with my iPhone book and I’ve been really happy with both. I’m reading the Objective C book cover to cover. I’m a little more than half-way through and really glad I chose to read it. I’ve read most of the iPhone book, but I use it more as a reference for specific tasks.
Getting up the learning curve with the native development tools for the iPhone has been extremely rewarding. The apps that generated are quick and small and just feel right. I’m definitely going to stick with the native development tools. I think the other tools have a place and I applaud those who are developing them for their efforts to simplify iPhone app development. For me, though, the key was simply allowing myself to take the time to really get up to speed rather than trying to shortcut the development process with a third-party tool. Your mileage may vary … and I’d love to hear your thoughts.
{ Comments on this entry are closed }








As an avid fan of the
In addition to being a fantastic piece of technology by itself, APC also provides meaningful
