Channels ▼


Smartphone Operating Systems: A Developer's Perspective

The Apple iPhone Platform

Apple introduced its first iPhone in September 2007, and 11 months later in July 2008 followed that with the iPhone 3G. By the end of 2008, the company sold over ten million iPhones, to capture one percent of the mobile phone market. Not a bad beginning for a newcomer to the industry. This success occurred despite the fact that the device has a low-resolution 2 megapixel camera, and lacked some common smartphone features such video recording, voice dialling, and a to-do list.

On the other hand, what makes the iPhone a success is that it dispensed with the phone keypad and function buttons. Instead, the iPhone uses a touch screen to display whatever the user needs at the moment: a web page, the latest e-mail, a map displaying your current location, an iPod music selection screen, and more. Getting to a feature usually takes a couple of taps on the screen. The iPhone applications display large, uncluttered interfaces, partially because the touch screen does not require a stylus, and Apple promotes the design goal that applications should accomplish one purpose. Apple is able to integrate its software well with the device because the company builds the iPhone's hardware and its software stack, similar to the smartphone stewards.

Some of the capabilities of the iPhone are:

  • It's a web browser, with a best of breed experience
  • It's an iPod, able to download, select and play music
  • It's an application platform, able to run useful utilities, access on-line content, and play games
  • It has enterprise support, such as synchronization to Exchange, and the ability to establish a VPN connection
  • Location-based APIs using the device's GPS feature provide position information, valuable for the creation of new forms of local presence applications and social networking
  • APIs permit access to accelerometer's data, allowing for the development of novel games

The iPhone has one of the best browsing experiences for a smartphone. Its WebKit-based Mobile Safari browser conforms to AJAX, ECMAScript 3, CSS 2.1 and partial CCS 3, DOM 2, HTML 4.01, and XHTML 1.0 standards, and renders most web sites accurately. The multi-touch gestures interface lets you to zoom in and interact with the content. On the other hand, there's no Flash support, and you can't download files. A built-in e-mail program uses a virtual keyboard to type in messages, eliminating the need to do leetspeak, and you can view certain types of mail attachments. Unfortunately, the mailer doesn't let you store these attachments as files in a directory, not does it support a landscape mode (unlike the browser). The smartphone is also an iPod, and lets you choose music using CoverFlow (a unique graphic selection mechanism) or from a typical list. On the negative side, for the iPhone 2.2 OS the Bluetooth stack lacks a A2DP profile, so your music choice can't be played through wireless stereo headphones. Everywhere you look, the iPhone exhibits this Jekyl-and-Hyde personality of doing certain things very well, but then there are those odd omissions.

The iPhone 3G can work in tandem with Microsoft Exhange Server 2003 and 2007 to support enterprise operations. For example, Exchange's ActiveSync technology can perform remote wipes on lost iPhones, and manages users logging to the corporate intranet. The smartphone supports VPN connections that can use Cisco IPSec, L2TP/IPSec, PPTP and certificate-based authentication (PKCS1, PKCS12). ActiveSync's direct push feature can send updates regarding e-mail, calender, and contacts to the device. Note that iPhone only allows one Exchange account. For non-Exchange users, Apple's MobileMe online service, after some fits and starts in 2008, now supports the push of e-mails and changes to the calendar and contacts.

To the end user, there's no concept of files on this platform (although they do lurk behind the UI curtain), which explains why you can't download content. Copy-and-paste is not supported for version 2.2. Only one third-party app executes at a time, which some competitors attempt to allude that the iPhone can't multitask. However, e-mail can be checked while music plays in the background, so obviously it can. What is going on here? To find an answer for that, we have to delve into the iPhone OS's software stack (Figure 3).

[Click image to view at full size]
Figure 3: iPhone software stack

Like the other mobile platforms, the topmost layer of the iPhone OS stack is the Applications layer. Apple applications can run concurrently, but only a single third-party application can run alongside of them. The platform doesn't have any Java implementation, so Java ME applications aren't allowed.

Beneath this layer is the Cocoa Touch layer. It consists of frameworks that manage the UI, such as capturing events, managing windows, and displaying graphics within these windows. Cocoa Touch is a subset of Apple's Cocoa, which are object-oriented frameworks written in Objective-C. Cocoa provides many classes, or components, from which you can build a fully-featured application. However, Cocoa Touch frameworks are tailored for the constraints of the smartphone platform. These frameworks strike the right balance between abstracting much of the iPhone's low-level hardware, while still enabling you to use device-specific features. For example, Cocoa Touch components manage most of the writing to the screen and playing media, yet there are APIs exposed that let you access the accelerometer and camera.

Further down the software stack is the Media layer. This layer manages all graphics rendering, audio generation, and playback of audio or video files. While Cocoa Touch provides the high-level means to generate animations and graphics, you can use the frameworks in this layer to exert fine-grained control over the display of your content. Three-dimensional objects are displayed with an OpenGL ES framework that conforms to the OpenGL ES 1.1 specification. This framework uses the device's hardware accelerators to provide full-screen animations at high frame rates, a valuable capability for games. This layer also uses Quartz, which is a vector-based graphics engine, to handle 2D drawing and graphics effects. The Quartz engine is identical to the one found in Mac OS X. The Core Animation frameworks support sophisticated animation and visual effects, with the image compositing required to accomplish them is performed in hardware. Playback and recording for audio files and streams is handled here, and a media player framework provides full-screen playback of video files of several format types.

The Core Services layer provides system services for the higher layers. It consists of frameworks and engines that support an address book, a SQL database (SQLite), Location services (using GPS coordinates), and networking services. A security framework manages the digital certificates, keys, and access policies that can protect an application's data.

The Core layer implements basic OS services, and consists of the kernel, drivers, and OS interfaces. The kernel is Mach based, and manages low-level functions such as virtual memory, POSIX threads, network connectivity (BSD sockets), math computations, file system access, and more. Only a select few higher-level frameworks have access to the kernel and drivers. If necessary, an application can indirectly access some of these services through C-based interfaces provided in a LibSystem library.

The iPhone OS stack has a rich legacy. Cocoa, the Mach kernel, and certain Core layer components had their start with the original 68030-based NexTSTEP computer in 1989. Over the years, this software was ported to PowerPC- and Intel-based platforms, and finally to the iPhone's ARM processor. As a consequence, the code has been subjected to rigorous examination during these ports. It has also undergone extensive field-testing, since the Cocoa frameworks, Quartz, and Mach kernel are part of Mac OS X for millions of Macintosh computers. The iPhone OS can be considered a highly stripped-down version of Mac OS X, thus bringing some of that operating system's reliability and multitasking capabilities to the platform.

However, there are fundamental differences between the iPhone OS and Mac OS X, given that one runs on an embedded smartphone and the other on a desktop computer. One difference is that there is very little RAM memory to spare in the iPhone. This is not surprising given that memory — not the processor — is usually the most expensive part in the device. The iPhone comes with 128 MB of RAM, and after the OS and Apple applications take their share, there can be anywhere from 40 MB to less than 4 MB of free RAM available for a third party application. Simply put, there's not much memory to run more than one additional application. The small amount of free memory and one-app-at-a-time requirement complicates any implementation of a copy-and-paste mechanism.

Furthermore, developers have determined that everything runs at root level in the iPhone. There had to be a design compromise behind this decision, but obviously every process executing with root privileges poses a potential security threat. As a security sandbox, the iPhone OS permits only one third-party application to run at a time, and not in the background.

iPhone Development Tools

You write iPhone applications using XCode, which is an IDE developed and maintained by Apple. Native applications are written in Objective-C, which is an object-oriented extension to C. Unlike C++, Objective-C is both a language and a runtime. Also, Objective-C's syntax for objected-oriented operations is significantly different from those used in C++. In short, it takes some effort to get familiar with the language's syntax and idiosyncrasies.

XCode's development tools allow you to debug iPhone applications in an iPhone simulator, and you can trace and place breakpoints at the source code level. The SDK that provides the Cocoa Touch frameworks and simulator is a free download. However, to run your program on an actual iPhone, the application must be signed, which requires that you purchase a signing certificate. With an enterprise signing certificate, you can distribute provision profiles that allow internally-developed applications to execute only on those iPhones that have installed the profile.

For web-based applications, the SDK provides Dashcode, which is a framework based on a Web page composed of HTML and Javascript. You can use DashCode's simulator to write and test your web application. You can also use several other third-party frameworks to write web applications, and debug these with Aptanna Studio's tools.

All iPhone applications are distributed via Apple's App Store, and they must be digitally signed. The App Stores uses the familiar iTunes front end to both display and handle purchases. Applications can be obtained through iTunes on the desktop computer with the iPhone tethered to it by a USB cable, or OTA via an App Store program on the iPhone. A developer's path to the money is clear-cut: seventy percent of the revenue goes to the developer, and thirty percent to Apple. There have been several instances where developers made small fortunes with a highly popular app. Other smarthphone vendors have quickly adopted similar revenue arrangements.

Apple reviews the application you submit before publishing it. This review can screen applications of questionable content or malicious code, but it's also been used to quash applications that "duplicate the functionality" of the iPhone. This is unfortunate, as developers could fill the gaps or improve the features of the device. For example, adding some useful Bluetooth profiles that supported stereo headsets, data synchronization, or the ability to implement multiplayer games would be useful, and make money.

Despite some missing features, the iPhone's ease-of-use advantage has made it a popular device. However, as this article points out, the smartphone's industry stewards are working on leveling the playing field in terms of the UI, and Apple must counter with additional features or perhaps different iPhone models (one with more memory) to continue its growth.

To this end, Apple announced an update in March, iPhone OS 3, that provides some of the missing features mentioned here, such as the A2DP profile for Bluetooth, voice recording, and copy-and-paste. Landscape mode is now supported by more Apple applications (the feature has always been available to developers), and push notification on the device side. You're still limited to running one third-party application at a time, and no background task are allowed. A beta became available at the time of the announcement, and it is expected to be released by mid-year. The update can be installed on all existing iPhones and iPhone 3Gs, although the older models might have fewer features. Apple declined to comment on this article.

iPhone Platform Summary


  • Best hand-held mobile platform that happens to be a phone.
  • Ease-of-use makes it a popular platform, overcoming its other shortcomings.
  • You can make some serious money with a successful app.


  • Have to learn Objective-C; is only smartphone platform that uses it.
  • Phone lacks some basic features other phones have.
  • Competitors will soon catch up on the UI.

New Release of iPhone OS Adds New and Missing Features

On March 17th, Apple announced the iPhone OS 3.0, which promises to fill in some of the missing features on the device, while adding new capabilities.

Missing features that have been added:

  • Copy-and-paste. System-wide pasteboards now allow you to cut, copy, and paste strings, URLs, colors and images between applications.

  • Audio recording. New classes enable audio recording and management. Various audio formats and sample rates are supported.

  • Push notification. According to Apple, push notification was significantly reworked on the server side to signal the presence of new or updated information. As now implemented, the iPhone OS 3.0 generates an audible or text alert that prompts the user to open the target application. This scheme eliminates the need for running a background task that saps battery life and poses a security risk.

  • Stereo headsets supported. The Bluetooth A2DP profile has been implemented.

  • Mapping support. Developers can now access the device's mapping services to embed navigation and GPS plotting into applications. However, for turn-by-turn support, developers will have to provide their own map content because of licensing issues.

  • More of the Apple native applications — notably the Mail app — now support landscape mode, and the virtual keyboard now works in this mode as well.

What's been added:

  • Support for accessories. The OS now supports the use of accessories connected to the iPhone either through its 30-pin docking connector or wirelessly via Bluetooth. Now that the device has been "opened", you can expect an entire ecosystem to build up around the device, much like the iPod has.

  • Peer to peer support. A new game framework allows you to connect to other iPhones or for multi-player games or collaboration over Bluetooth without pairing devices. This framework implements peer-to-peer connectivity using Bonjour, Apple's service discovery protocol. Bonjour conceals the gritty details required to locate and establish network sessions with other networked devices.

  • Application purchase support. Formerly, to add new content — such as new game levels — to an iPhone app, you had to submit a new application to Apple for approval and posting. With iPhone OS 3, developers can now allow users, from within the application, to purchase and obtain new content. New Store Kit classes manage the financial transaction details, and all content is transferred through iTunes. This capability is only available to paid (not free) applications, and Apple takes 30 percent of the revenue.

  • System wide search. You can use Spotlight (a search sevice already present in Mac OS X) to search for content in various applications.

What's still missing:

  • No voice dial.

  • No video recording. Considering the quality of the iPhone camera, this isn't a surprise.

  • To-Dos still MIA.

  • No background tasking.

The update will be available by mid-year, and can be installed on all existing iPhone models through an iTunes download. It is also available for iPod Touches, for a small fee. Apple declined to comment on this article.


Related Reading

More Insights

Currently we allow the following HTML tags in comments:

Single tags

These tags can be used alone and don't need an ending tag.

<br> Defines a single line break

<hr> Defines a horizontal line

Matching tags

These require an ending tag - e.g. <i>italic text</i>

<a> Defines an anchor

<b> Defines bold text

<big> Defines big text

<blockquote> Defines a long quotation

<caption> Defines a table caption

<cite> Defines a citation

<code> Defines computer code text

<em> Defines emphasized text

<fieldset> Defines a border around elements in a form

<h1> This is heading 1

<h2> This is heading 2

<h3> This is heading 3

<h4> This is heading 4

<h5> This is heading 5

<h6> This is heading 6

<i> Defines italic text

<p> Defines a paragraph

<pre> Defines preformatted text

<q> Defines a short quotation

<samp> Defines sample computer code text

<small> Defines small text

<span> Defines a section in a document

<s> Defines strikethrough text

<strike> Defines strikethrough text

<strong> Defines strong text

<sub> Defines subscripted text

<sup> Defines superscripted text

<u> Defines underlined text

Dr. Dobb's encourages readers to engage in spirited, healthy debate, including taking us to task. However, Dr. Dobb's moderates all comments posted to our site, and reserves the right to modify or remove any content that it determines to be derogatory, offensive, inflammatory, vulgar, irrelevant/off-topic, racist or obvious marketing or spam. Dr. Dobb's further reserves the right to disable the profile of any commenter participating in said activities.

Disqus Tips To upload an avatar photo, first complete your Disqus profile. | View the list of supported HTML tags you can use to style comments. | Please read our commenting policy.