Thursday, October 29, 2009

Diving into the iPhone AppStore - Part 1

The iPhone madness is resonating throughout the world and the shock wave has reached Sri Lanka as well. The madness is two-fold; iPhone User madness and iPhone Developer madness! I've been fortunate enough to be a part of the staggering iPhone user base for one and half years now. Thanks to my new employer I've been able get my hands on "the other side" as well, that is, the iPhone development arena!

I'm writing this since several people have asked me about iPhone development procedures, about the AppStore and such. This should help any would-be-iPhone-developer to know about prerequisites, special considerations and possible frustrations! that he or she is going to face.

Here are the steps that you should follow to get into iPhone development using iPhoneSDK.

1. Get a Mac!

Can't I use Windows (or Linux)? Of course not! All official iPhone development tools are developed by Apple and they are Mac-only!

Well, this is costly! but you have several choices here. If you have the money, you could go for an iMac. That's apple's desktop class computer and it's sooooo pretty! Next choice would be a MacBook Pro or a lower end white MacBook. If you have a spare monitor and keyboard/mouse, you can go for a MacMini (it's kind of cheap) and plug your own monitor and keyboard to it.

If you really need it, for the initial stage of experimenting, you can try out hacked versions of MaxOS X on your PC. But these have lot of glitches in them and it's hard to get them working. More info at

MacOS X version requirement
iPhoneSDK have a minimum requirement of a certain version of MacOS X to be installed. The latest SDK version (3.1.2) requires MacOS X 10.5.8 to work. The requirement tend to elevate with most updates to the iPhoneSDK. So make sure you have necessary software updates installed on the OS.

2. iPhoneSDK

iPhoneSDK has more or less the same development tools, libraries and programming paradigms that MacOS X uses. The reason for this is that, iPhoneOS is just MacOS X with a different UI running on different hardware. In fact, apple has built iPhoneOS with the same source files of MacOS X Leopard kernel and most of the system services and libraries. So it has the same power and the architecture of the desktop class MacOS X. If you are a Mac developer (which I'm not), you'll find iPhoneSDK surprisingly similar to the development tools you've been using up to now. The only major deviation that the iPhoneOS has from MacOS X, is the UI, which is a complete rethought from top to bottom.

XCode is the IDE you'll be using. Although you are not required to use XCode, it has really nice and elegant features making it the standard choice of Mac and iPhone developers (much like Microsoft Visual Studio). XCode and other supporting development tools are freely available on the iPhone developer connection website.

In iPhoneSDK, You'll have to write code primarily in Objective-C. It is essentially a super set of C, meaning you can code in pure C if you want. You can think of Objective-C as an extension library to C. All it does is providing an object-oriented like syntax to access underlying C entities. The syntax may appear weird at first since it's significantly different from the "dot" notation we are used to in C-style languages. But within 10 minutes or so, you can get the hang of it.

Since we are talking about native application development here, there are no fancy runtimes available for you. Actually, Objective-C itself has a runtime to do stuff like wrapping/unwrapping Objective-C classes from and to their equivalent C data structures. But it's not as powerful as .Net CLR or Java virtual machine. In my opinion, iPhoneSDK development stands between Win32 native development and .Net development. You don't have to go into so deep as native Windows programming, but you don't also have a large runtime feature set like .Net. For example, Objective-C runtime, doesn't have a garbage collector so you have to release resources manually when you finish using them. Somewhat similar to free() in C but not exactly the same. You'll understand these fine differenciations when you read the subject matter.

For more info on everything regarding iPhone SDK and AppStore, register on iPhone Developer Connection.

3. Testing the apps

iPhoneSDK comes with a nice iPhone simulator that you can use to test your applications. Obviously this doesn't have all the features of a real iPhone but you can emulate most of the functionality here. One thing to keep in mind is that DO NOT test application performance in the emulator. Since the emulator runs using your desktop CPU and hardware, applications run significantly faster on it. But it should be enough for most day-to-day business class applications.

If you do need to test your application on a real device however, you might want to consider buying an iPhone or an iPodTouch (iPodTouch lacks some hardware features the iPhone has). In addition to that, you need to register on the iPhone Developer Program ($99/year) in order to acquire a developer certificate. You need that certificate to test your applications on a real iPhone.