An Open Source Recipe for the iPhone

The platform that has defined "cool" for years has not had a reputation for being an open platform, but that hasn't discouraged a number of open source projects for iPhone/iPod Touch.

You could make a strong argument that Apple “bet wrong” decades ago when they decided to keep the doors closed to officially sanctioned clones of their personal and business computing hardware platforms. IBM on the other hand encouraged the “PC clones” and the consequence was a booming market for all things “PC-compatible”. So successful was the model that untold wealth was created and productivity improved (arguably enabled?) in the cascading markets impacted by the PC revolution. If you doubt that, just ask yourself how many “desk jobs” use PC’s versus other platforms, including the ol’ reliable pen and paper.

Fast forward to the year 2007 and Apple Computer is still around, and after many dark years, they are thriving thanks to their diversification into the mobile music market with the ubiquitous iPod product line and the loyalty of the high-end graphic designer market for their computer and laptop lines. Building upon their iPod success, Apple introduced the iPhone in January of 2007 and simultaneously dropped the word “Computer” from their name — now known simply as “Apple”. With the announcement and subsequent iPhone introduction in June of 2007 — a mere 24 months ago — and the mobile device market will never be the same.

Today, virtually every new phone is contrasted to the iPhone. Some models are designed as “iPhone Killers” — many of the features of the iPhone but at a better price point or on an (arguably) better network. Or a phone is introduced as “No iPhone, but a great value”. Just like we saw with the success of the IBM PC years ago, the success of the iPhone has spawned a commercial market that cannot be ignored. The iPhone’s success has been like a Twister — moving through markets causing havoc and drawing in converts in its wake.

A revolution?

Consumer and business users alike have purchased Mac-Books thanks to their new found affection for the iPhone. All of a sudden, people “get it” and are making the switch to Apple/Mac. Throw in some clever and entertaining marketing, “Hello, I’m a PC. Hi, I’m a Mac….” and you have yourself a bit of a revolution on your hands. And in a particularly calculated move, all iPhone development must take place on an Intel-based Mac. That has brought developers (such as myself) grudgingly into the Apple fold, at least in part. And at $99/year to participate in the developer community (and $299 for enterprise development memberships), this has created an additional revenue stream for Apple. The extremely popular AppStore takes a healthy 30% cut of all products sold, generating even more revenue for Apple, though some reports indicate that this only covers the cost of running the store.

One way or another, Apple iPhone (and iPod Touch) is a market mover that forces developers to make a conscious decision to embrace or avoid the platform. And for the first time in who knows how long — we have to make that choice about Apple — developers can no longer simply ignore Apple. So what does this have to do with open source? Not surprisingly, open source has made inroads into this market and though it looks much different than the Google/Open Handset Alliance approach with Android, it is worth examining the open source community surrounding the iPhone platform.

Developing for iPhone

Most discussions of software development with open source starts down the “install the latest version of Eclipse…” path. Though that may have some legs, we’re not going to go there right now. We’re going to take a very quick tour of “belt and suspenders” iPhone development the way Apple intends it to be done and then examine one interesting (and fun) open source project for iPhone. Don’t worry, it won’t take too long and while not meant to be exhaustive or even detailed this will (hopefully) be helpful to those new to the platform who are still lurking in the shadows, not ready to admit they are looking at developing on a Mac!

The best way to get started with iPhone development is to visit http://developer.apple.com/iphone/ and begin perusing the numerous materials there. If you decide to stick your toe into the water, here are the basic steps you will take:

  • Create an Apple id account.
  • Sign up as a developer.
  • Go Buy an Intel-based Mac. Don’t worry, it is now cool to be seen in an Apple store.
  • Figure out how to use the Mac. OK, perhaps more of a confession on my part — but not too difficult a task.
  • Download and install the latest iPhone SDK.
  • Begin navigating the X-Code platform. Just hit Apple-Enter and hopefully your application will launch in the simulator. Good things will follow. You get to use gdb!
  • Go read more about Objective-C, because it is a bit different from what you are accustomed to if you are an ANSI C or Java developer. Object oriented, yes. Powerful, very. A bit of a learning curve, you bet!

Now that you’re ready for your first day as an iPhone/iPod Touch developer, now what? Are there any starting points? Well, certainly. You can start with some of the application design templates shipped with X-Code and the Cocoa Touch framework. And of course there are a number of iPhone development books available. But really, where to next? Here’s my story.

Saved by the (Sapus) Tongue

I had the opportunity to work on a game/entertainment project with a friend from church. He’s an artist and wanted some assistance getting some of his art incorporated into some game ideas for iPhone. To date virtually all of the software I have written (including iPhone) is either for business customers moving records around or for embedded systems moving data around. So, what if what I really want to do is write a game? Where do I start? Well, here comes open source to the rescue! In the process of researching just the best way to do this, I stumbled across an open source gaming/graphics library that really caught my eye.

cocos2d is an open source framework for constructing 2D games and other graphical/interactive applications, written in python. The folks at Sapus Media are attempting to make a living at porting this framework to iPhone. The code is hosted with Google code hosting (http://code.google.com/p/cocos2d-iphone/) and as you can see from their forum the library already has numerous game titles to its credit.

Its licensing model permits its use in closed-source applications — if you extend or improve the library, you are encouraged to contribute your enhancements back to the code base. I personally feel that this hybrid model is the best of all worlds — it is the sweet-spot of open source because it is the critical intersection of collaboration and enabling commercial endeavors. For me that means having a solid code foundation to write applications and the opportunity to earn enough money to buy bread and cheese for my kids. Isn’t it ironic that the only license files we tend to read are the open source ones? Anyway, if you’re interested in doing just that you can read the license here.

Now, back to the Tongue thing. The game (Sapus Tongue) is an addictive game available for purchase in the AppStore with a free version available for download as “bait”. Sapus Media, the folks leading this open source project, is supporting itself (at least in part) by making the source code of Sapus Tongue available to developers for a fee. The idea being that if you can see how a commercial application is constructed using the open source library, it’s a great place to start and an asset worth investing in. Sounds like a reasonable assumption, though I haven’t taken the plunge just yet.

Regarding the game itself, so far my scores are a bit anemic, but I haven’t given up yet. I just can’t let my kids see it — or I’ll never get my device back and my friend will be wondering why those applications are not getting written…

Fatal error: Call to undefined function aa_author_bios() in /opt/apache/dms/b2b/linux-mag.com/site/www/htdocs/wp-content/themes/linuxmag/single.php on line 62