Preface

So, you want to write applications for the iPhone. The first thing you should know is that the iPhone is by and large a closed device, and Apple has taken steps to lock users out of the operating system. This hasn't stopped people. In October 2007, Apple announced in an earnings statement that over 250,000 units had been sold with the intent of unlocking them for use on other networks. Within the first month of v1.1's software release, Nicholas Penree's jailbreakme.com site logged over one million units that were freed to run third-party applications. Sites hosting iPhone cracking tools have reported record traffic, and even Apple's own employees traipse around the Genius Bar touting their hacked devices. Well-respected hackers joined the effort to crack the iPhone, and once in, realized it's just as elegant on the inside—a well-planned mobile platform well worth developing applications on. Within a few months, a free, open source (http://open-source.org) compiler for building iPhone applications was released—not by Apple, but by the open source community. Today, full-featured iPhone applications are ubiquitous. And all of this was accomplished on a device that was intended to be closed.

Apple finally woke up to the fact that developers were not satisfied with Safari-based applications. In late 2007, they announced an SDK for the iPhone to be released the first quarter of 2008, but as of the time of this writing, we don't know what the availability will be, or what restrictions will be placed on it. What we do have today, however, is almost as good and in some ways better. The free SDK, affectionately called "the tool chain," isn't tied down with licensing, nor is it exclusive to running only on Apple's operating system. In fact, a Linux user (and soon Windows users) can build and install applications on their iPhone without ever touching a Mac.

The interfaces used by the free tool chain are in every way identical to what Apple must release with their own SDK. The frameworks available on the iPhone employ a standard set of interfaces used by Apple's preloaded iPhone applications. All major tasks are performed by these frameworks, including the entire user interface, playing sounds and music, working with graphics and animation, and even displaying web pages. Within the first few months of the iPhone's high-profile life in the public market, the iPhone hacking community extracted these interfaces and built their own software development kit.

So this book, which was written based on the free tool chain, uses the same code that Apple's XCode or any other compiler would need to use to compile iPhone applications. Should Apple follow through with the release of a native SDK, the classes, methods, and examples presented in this book are very likely to work with both SDKs. In fact, Apple would have to rewrite every framework—and every single application on the iPhone—to make this book obsolete.

With tool chain in hand, and many sleepless nights of tomhackery, the community has been able to learn how to use the frameworks and interfaces available to design spectacular third-party applications. This book walks through the frameworks that are key to designing this full-featured software on the iPhone, with pointers to tools that are available to take advantage of the other frameworks not documented here.

The iPhone is a superb device, and in spite of the politics surrounding its availability to developers, the community is growing fast. With or without Apple's help, the iPhone is likely to give birth to many commercial markets for itself, and possibly grow beyond the success of its predecessors, the PocketPCs and the Symbians that formerly owned the mobile market space.

As you read this book, you probably won't realize just how good you've got it. The simplicity you'll see in this book reflects thousands of hours of work by the active development community chipping away at the nearly impossible challenges that were involved in this task. The old school methods for getting anything done on the iPhone were laborious if not exhausting, and could have filled up volumes of books alone. Even after we figured out how to jailbreak the very first iPhone, we couldn't do anything with it until we came up with a grand scheme to fool it into running SSH. It took another month beyond that before the first GUI application was even written.

Work continues today to figure out many of the proprietary interfaces on the iPhone, and we welcome anyone into the community with the know-how and perseverance to join us in this endeavor.

Audience for This Book

You'll need some prior knowledge of coding to find this book useful. The iPhone framework uses Objective-C, which we'll introduce you to in Chapter 2. The good news is that you can also use C and C++ in your applications, so anyone with preexisting knowledge should be able to pick it up pretty quickly. If you don't understand C or C++, there are many books available on the subject. This book isn't a primer for any of these languages, but rather is designed to explain the proprietary classes and methods needed to write iPhone-specific applications.

Get iPhone Open Application Development now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.