You are here: Home / The iPhone is defective by design.

The iPhone is defective by design.

"Our Advice about the iPhone is simple: it's defective by design. It deprives you of your freedom. Nobody should buy it. Nobody should write software for it." --FSF

References:

http://www.linux.com/archive/feature/136463

Book review: Open iPhone Application Development

By Nathan Willis on June 03, 2008 (9:00:00 PM)

Johnathan Zdziarski's book Open iPhone Application Development is a guide writing applications for the iPhone without engaging the restrictions of Apple's official software development kit (SDK). The book takes readers on a concise tour of iPhone jailbreaking, setting up the free compiler tool chain, writing basic Objective-C apps, and the available libraries and APIs. Apple might not like this book, but if you need to develop for the iPhone or just want to learn more about how it works, you'll be hard-pressed to find a better practical resource.

Zdziarski belongs to a group that calls itself the iPhone Dev Team. Despite the official-sounding name, the group has no affiliation with Apple. Instead, it works on jailbreaking iPhone software, reverse-engineering the iPhone APIs, and supporting a free software tool chain for the device -- including cross-compiler, linker, assembler, and class headers. There are other independent projects whose work overlaps with iPhone Dev Team's, but the book is understandably focused on the work Zdziarski and his peers have produced.

What's inside

The book's first chapter details the restrictions of the iPhone's software that make it impossible to develop for an out-of-the-box device. This includes the chrooted environment in which all user apps run and the stripped-down BSD operating system. Zdziarski explains how to get around both. The chapter includes links to several Web resources that host jailbreaking tools -- methods for circumventing the chroot jail. Jailbreaking is not related to unlocking the iPhone, which is the process of getting the phone to work with cellular carriers other than AT&T. Some tools do both, but you do not need to unlock the iPhone to develop for it.

Chapter two begins with an overview of iPhone applications, including the .app structure familiar to OS X users and variations unique to the iPhone. It then explains how to install the iPhone Dev Team's open source development tool chain, from GNU prerequisites like Bison, Flex, and GCC, to configuring, patching, and compiling the tools themselves. Next, it walks through an example of the entire process of compiling, linking, packaging, and installing an iPhone application. Finally, it provides a brief tour of Objective-C, the language in which iPhone frameworks and apps are written.

The bulk of the book, chapters three through seven, is devoted to exploring the native frameworks and APIs of the iPhone system, and explaining how to use them in your own app. Chapter three cover UIKit, the basic building block of drawing interface elements to the screen. Chapter four covers event handling and the Graphics Services framework, which processes finger taps and screen coordinates. Chapter five covers video and animation, including transformations. Chapter six covers audio processing, which is important enough to Apple that the iPhone actually has three separate APIs for working with sound: CoreAudio, Celestial, and Audio Toolbox. Chapter seven covers "rich" interface elements, including many of the bling effects showcased in iPhone television commercials, such as sliders, on-screen keyboards, and screen orientation.

The last chapter is an appendix containing useful miscellany: recipes for isolated but important tasks and explanations to accompany them. These include formulas to let your app do interesting things, such as initiate a phone call, activate the vibration alarm, launch a URL in the Web browser, or build a CoverFlow item view. But they also include useful debugging aids, such as taking a screenshot and dumping user interface data to file. Since there is no debugger for the iPhone, these are helpful additions to have at your disposal.

What's to like

The book's biggest plus is its role as unofficial documentation. A considerable amount of reverse-engineering has gone into decoding the iPhone's constituent frameworks and APIs. A few of them are shared with desktop OS X, and thus are documented in places not requiring a non-disclosure agreement (NDA), but that is the exception, and in several places the iPhone and desktop OS X equivalents behave differently.

The frameworks are explained top-down, describing how they fit into the iPhone's interface paradigm -- for example, why the transitions between Views consist of page-flipping and peeling effects, instead of the more familiar tabs. The iPhone treats application screens as pages in a book, better befitting its handheld size and touch-sensitivity. You might not find that metaphor intuitive, but understanding it makes understanding UIKit easier.

The author provides detail for each class and method, and includes both code snippets and full-blown example apps as illustrations. I particularly appreciated the way each example app was followed by a "What's Going On" step-by-step explanation of the code. If you haven't looked at a particular section in a while, following the flow of the program through What's Going On is a great memory-refresher.

There are pointers to Apple's online documentation when it is publicly available, and it is amusing to see candor about the remaining, intermittent gaps -- such as the Fence ID attribute on page 75: "Used internally. We have no idea what it means."

The frankness of that comment says a lot about the style of the book: practical. It is not an Apple fanboy love poem, and it doesn't waste space. At just 260 pages, it gets right to the point about each framework, class, and example, and it moves on. It is geared at the experienced programmer who is familiar with OS X on the desktop, and wants or needs to get started developing on the iPhone right away.

What's to improve

In fact, if I had to come up with a weakness in the text, the only real candidate is that the book caters too much to OS X developers. To be sure, Mac users were the bulk of the first round of iPhone buyers, but new iPhone developers are coming from the Symbian, Palm, and Windows Mobile realms, too. An OS X veteran might understand CoreAudio, but need an explanation of suspending program state when a phone calls interrupts the user -- but a Symbian veteran might need just the opposite.

Similarly, the iPhone Dev Team tool chain supports both OS X and Linux as its desktop platforms, and the book takes a brief look at integrating the tool chain with OS X's native IDE, XCode. It does not explore comparable integration with Linux IDEs.

On a different note entirely, if you pick up the book expecting to find a detailed explanation of certain iPhone exploits -- the ones used to jailbreak and unlock the device, for example -- you will be disappointed. This is not The iPhone Hacker's Guide; it is a guide to writing useful applications. As a practical matter, any information included about the jailbreaking process itself would quickly get out-of-date, but more than that, it is really irrelevant.

Born unfree

Finally, if you are interested in writing free software for the iPhone, you may be wondering how the book fits into the grander scheme of iPhone development. If you recall, in April we looked at the legal issues surrounding Apple's official SDK, with the help of the Free Software Foundation's (FSF) Licensing Compliance Officer Brett Smith. Smith's assessment of the SDK's terms was that it was incompatible with the GPL. Moreover, SDK users are bound by a NDA that prevents them from publishing any of the resources included in the SDK's documentation.

The iPhone Dev Team's documentation of iPhone frameworks and APIs is not bound by restriction, and using its tool chain you can compile and install applications without submitting them to Apple to be cryptographically signed -- the "TiVoization" requirement that inhibits SDK-derived projects from being GPLv3-compatible. So in that sense, apps written and compiled using the iPhone Dev Team's resources could be released under free software licenses. But, of course, they would not be installable or runnable on off-the-shelf iPhones -- only on other jailbroken devices.

Don't expect the FSF to promote GNU on the iPhone, though. As Smith told me, "What does FSF advise aspiring developers of free software for the iPhone?" isn't the question, because FSF objects to the iPhone itself. "This is why we fought so hard and endured so much criticism to get anti-TiVoization clauses into GPLv3. We don't think it would merely be nice if people could tinker with the devices they buy. We think it's fundamental to a free society that they be able to do so. Our advice about the iPhone is simple: it's defective by design. It deprives you of your freedom. Nobody should buy it. Nobody should write software for it."

Zdziarski is up-front about the iPhone's non-free-ness, too. Paragraph one of chapter one begins with a clear warning to that effect. "The iPhone is a closed device. We can't say this enough. Up to and including version 1.1.x of the iPhone software, users have been locked out of the operating system." The difference, of course, is that Zdziarski proceeds to explain how to break through those locks, and details everything you will see once you get past them.

There is a possibility that the free availability of such documentation will make the NDA-bound official SDK less appealing and entice Apple to release more docs to the public. As Zdziarski notes in the book, Apple only agreed to release an SDK when developers found the company's original Web-app-only offering unsatisfactory and began jailbreaking the devices en masse. So perhaps the company is capable of learning.

Fortunately, you do not have to wait for that to happen. If you need or want to develop for the iPhone -- and you find the restrictions of the Apple SDK onerous -- you can do so today. Zdziarski's iPhone Open Application Development is an excellent place to start, both for its introduction to the platform, and for its documentation of the APIs and frameworks that make the platform run.

Navigation