Daniel Eran Dilger
Random header image... Refresh for more!

iPhone OS X Architecture: Cocoa Frameworks and Mobile Mac Apps

iPhone OS X Architecture: Cocoa Frameworks and Mobile Mac Apps
Daniel Eran Dilger
Continuing on the series looking at the architecture of the iPhone, here’s a look at the Mac system frameworks and application environment on the iPhone.

[Leopard, Vista and the iPhone OS X Architecture]
[iPhone OS X Architecture: the Mach Kernel and RAM]
[iPhone OS X Architecture: Disk, Shell, and Password Security]
[iPhone OS X Architecture: the BSD Unix Userland]

The iPhone’s OS Domains.
Outside of the invisible Unix directories, Mac OS X maintains its own three primary domains, which were largely inherited from NeXTSTEP. These mirrors aspects of the domains found in Unix, but strives to make things clearer and more distinct. They are the:

System domain contains software Apple installs. Includes everything under /System.
Local domain contains machine specific software. Includes everything inside /Library and /Applications
User domain contains user specific files. Includes individual user accounts inside /Users.

This system of domains enables Mac OS X to protect and isolate the System–which is intended to not change unless Apple updates it–from the changes made by a local machine administrator and the changes made by individual users.

Mac OS X vs OS X.
The iPhone’s OS X installation is remarkably similar to the standard desktop Mac environment and that of its slower cousin, the Apple TV. There are a number of key differences however.

User Domain: As noted earlier in the BSD Unix userland article, the iPhone doesn’t need to accommodate different users, so there is no /Users folder. Everything is stuffed in the /usr directory.

Apple may never need to include multiple user accounts on the iPhone, but as reader ZU pointed out, it might make some sense for Apple to later add a mechanism similar to the Mac’s parental controls, where the iPhone could be put into one of several security modes to grant limited access to a holder.

This could accommodate the iPhone–or a future version of the iPod–being used in a limited kiosk-only mode for multimedia walking tours, entering a phone-only mode when lending it out, or in actual use as a parental control for limiting kids’ use of certain applications, visiting certain hosts, or limiting hours of use.

200710281853

Local Domain: Like Mac OS X, the iPhone’s applications are stored in /Applications. There’s not much in /Library beyond ringtones and wallpapers, as there’s no provision for third party additions or installations by a machine administrator. That leaves the local domain fairly slim, with bundles of the iPhone’s Cocoa apps:

• Calculator.app
• DemoApp.app
• Maps.app
• MobileCal.app
• MobileMail.app
• MobileMusicPlayer.app
• MobileNotes.app
• MobilePhone.app
• MobileSMS.app
• MobileSafari.app
• MobileSlideShow.app
• MobileTimer.app
• Preferences.app
• Stocks.app
• Weather.app
• YouTube.app
• FieldTest.app (invoked by dialing *3001#12345#* this displays technical information about the network)

Application Bundles: Mac OS X applications appear to be files in the Finder, but are usually bundles. In the world of Mac OS X, a bundle is a specially marked folder that is designed to behave like a file, simplifying interaction for the user and making application installation an effortless drag and drop experience.

An application bundle on Mac OS X houses a Contents folder holding the subfolders:

• Frameworks
• Plugins
• Resources
• Mac OS

This outline makes it easy for developers to organize the files their application needs without requiring the user to manage directories of stray files within various directories, and without packing all sorts of support files directly inside the actual application’s binary executable file.

Bundles also helped in the transition from Classic Mac OS 9 to Mac OS X by accounting for differences in the Classic Environment on X and the native environment on 9.

Of course, the iPhone has no need to support a transition environment from OS 9, so its bundles are simpler. They only contain an application, its localizations (currently English only), supporting graphics and other files.

[Bundle Programming Guide: About Bundles – Apple]

The most familiar iPhone application isn’t listed above: SpringBoard. It acts like the iPhone’s Finder, Dock and Desktop, similar to the Apple TV’s BackRow application. Like BackRow and the Finder, it resides in the…

System Domain: Like Mac OS X, the iPhone has a System directory containing its Cocoa frameworks and system utilities. The Mac OS X Finder doesn’t live in /Applications, it’s hidden away in /System/Library/CoreServices, along with the Dock, Help, System Update, Spotlight and a variety of faceless helper apps that act as part of the Finder’s desktop environment.

Apple TV is laid out similarly, replacing the Finder with BackRow. Unsurprisingly, iPhone follows the same approach with its home application. SpringBoard manages the familiar starting point of app icons, along with the top info bar of the clock, network, and battery indicators and the bottom dock bar with its four main apps.

Next to SpringBoard in CoreServices is the mDNSResponder bundle, the less friendly name of Bonjour. The iPhone’s Bonjour is currently silent, but the fact that this is here–despite being just a shell at present–hints at significant new features Apple will deliver in the future, which I’ll cover in a future article.

Outside of CoreServices in the System domain are folders of sound effects, cache files, hardware drivers, file system support (it’s HFS), Fonts, Frameworks, Internet Plugins (currently only QuickTime), LaunchDaemons, Lockdown, the meat of Settings.app, and SystemConfiguration.

Frameworks contains some interesting bits. In addition to the familiar Address Book, Calendar, BlueTooth, Foundation, CoreAudio, CoreGraphics, CoreVideo, JavaScriptCore, WebCore and WebKit frameworks are:

• Celestial, related to sound ceilings and vibration settings.
• CoreSurface, manages multitouch input.
• TelephonyUI, manages call dialing and answer features and contains the dial tones.
• URLify, apparently helps recognize phone numbers in web pages and makes them dial-able links.
• LayerKit, the former name for Leopard’s Core Animation.

There are at least three libraries related to the iPhone’s PowerVR MBX 3D graphics processor, which was developed by Imagination Technologies Group as a coprocessor for the ARM.

• MBX2D
• MBXConnect
• OpenGLES (OpenGL ES is a graphics library for mobile embedded systems. It is also used by Symbian.)

Samsung licensed the PowerVR graphics accelerator back in 2004 and appears to have integrated it together with an ARM core on the “System on a Chip” processor used in the iPhone.

[PowerVR MBX in iPhone – Beyond3D Forum]
[ARM licenses partner’s graphics core to Samsung – EEE Times]
[Origins: Why the iPhone is ARM, and isn’t Symbian]

Mysterious Frameworks.
And then there are a few more mysterious frameworks:

• MeCCA.framework
• GMM.framework
• DeviceLink.framework
• IAP.framework
• OfficeImport.framework

• UIKit.framework (blogger Fraser Speirs speculates this may be “the iPhone’s version of AppKit”)

[Dissecting an iPhone Crash Log – Fraser Speirs]

PreferenceBundles function within the Settings application, similar to System Preferences panes in Mac OS X, although not all of the settings modules are presented in the iPhone’s UI. Installed are:

• AirPortSettings for WiFi networking
• BluetoothSettings
• CarrierSettings (interesting)
• EDGESettings (not configurable in Settings)
• Wallpaper
• VPN
• various mobile application settings

SystemConfiguration includes both Settings and some internally configured items:

• Aeropuerto likely involves airplane mode, apparently in Spanish to distinguish it from AirPort WiFi settings.

• Various network and power management settings
• Profiler, which lists three items apparently used by the service provider:

• SPLogsReporter
• SPNetworkReporter
• SPOSReporter

Using the Apps on the iPhone.
Sitting on top of the Mach, BSD, and Mac layers on the iPhone is its slick user interface. I’ll delve into how each wing of its applications stack up, what’s missing and what future potential lies suggested in hints.

What do you think? I really like to hear from readers. Comment in the Forum or email me with your ideas.

Like reading RoughlyDrafted? Share articles with your friends, link from your blog, and subscribe to my podcast! Submit to Reddit or Slashdot, or consider making a small donation supporting this site. Thanks!