1.2. Installing the iPhone SDK

The iPhone began life as a closed platform. Preceding the release of Apple's iPhone SDK, the open source community successfully hacked into the device and wrote a home-brew compiler to build applications. Later, Apple hired some of the developers of this open source tool chain to design the iPhone SDK. As a result, the two behave in a similar fashion: as cross-compilers. A cross-compiler is a compiler that builds executables for a different architecture than the one it's running on. Here, the iPhone SDK compiler runs on a Mac OS X desktop machine, but builds executables for the iPhone's ARM architecture.



The open source iPhone tool chain can run on many different platforms, including natively right on the iPhone, but is not supported by Apple. You'll need to use the SDK to design applications suitable for distribution on the AppStore, which means your developers will all needs Macs.

The commands and pathnames provided throughout this book assume that you've used the procedures from this chapter to install the iPhone SDK in the recommended way. Apple releases new versions of the SDK periodically, so its setup can sometimes change. Newer versions are available on the Apple Developer Connection website at http://developer.apple.com/iphone.

1.2.1. What You'll Need

The iPhone SDK requires an Intel-based Mac running Mac OS X Leopard. Each version of the SDK has its own particular operating system version requirements. You'll need about 3.5GB of disk space for the SDK, along with extra disk space for your projects.

While the following aren't required, they will certainly make developing iPhone applications easier. Apple developer key

You use Apple developer keys to sign applications so that you can install them on development iPhones. Apple gives developer keys to those accepted into Apple's developer program. To sign up, visit the Apple Developer Connection website at http://developer.apple.com/iphone. Apple offers two tracks for developers: a standard track and an enterprise track. The standard track provides a basic developer key, allowing you to install applications on your iPhone from Xcode. As a developer, you'll be able to submit your applications for distribution in the AppStore. The enterprise track, which is more expensive, is designed for enterprises that will be using applications internally or with selected partners instead of distributing them through the AppStore. This track includes additional provisioning keys for large enterprises. An iPhone

You will need an iPhone, of course, if you want to test applications on an actual iPhone device, as opposed to using the iPhone simulator platform. This is strongly recommended. The iPhone needs to be running a version of firmware supported by your particular version of the SDK.

1.2.2. The iPhone Simulator

Without an Apple developer key or an iPhone, you'll have to test your applications using the iPhone simulator. The iPhone simulator is a target platform that you can use to deploy and test iPhone applications on the desktop. The simulator provides an iPhone-like environment with menu options to simulate locks, screen rotations, and other basic iPhone events. It is greatly limited, however, because your desktop machine lacks the necessary hardware to perform certain tasks. Using the simulator, you will get a general "feel" for how your application might function, but you will also miss some important functionality:

  • The Core Location API will not be able to provide your GPS coordinates, but may provide you with sample data or broad location-based information, as available for your network.

  • The accelerometer API will not be available to the application.

  • The simulator is limited to only some gestures, such as pinch, and will not support more than two fingers or indiscriminate multi-touch.

  • The application may not initiate phone calls.

  • The EDGE/3G network will be inaccessible, but network queries will use your Internet connection as available.

  • The camera and microphone APIs may not function. If your application enables these features, it may suffer from a fatal exception.

  • Only certain preloaded iPhone applications will be available. These include Contacts, Safari, Photos, and Settings applications.

  • You won't be able to see whether any parts of your application might tax the iPhone's CPU or memory, because your desktop machine will have greater resources to run your application. Slow graphics or other issues might not be noticed until it is tested on an actual iPhone.

1.2.3. Downloading and Installing the iPhone SDK

Download the iPhone SDK from the Apple Developer Connection website at http://developer.apple.com/iphone. You will be required to create an account if you don't already have one. This is free. The entire distribution runs about 2 GB, so you will want to download it over a high speed Internet connection. The SDK itself comes in the form of a disk image file, which will be placed in your Downloads folder by default.

Double-click the disk image to mount it. You should now see the volume iPhone SDK mounted. This will appear on both the sidebar of your Finder and on the desktop. Open the volume and a window will appear.

Inside this window, you will see a package labeled iPhone SDK. Double-click this package to begin the installation process. After agreeing to the various licensing provisions, you will be presented with the installation screen shown in Figure 1-1.

Figure 1-1. The iPhone SDK installer

Ensure that the iPhone SDK option is checked and click Continue. The installer will then install Xcode and the iPhone SDK into /Developer on your desktop machine.

That's it! You've now installed the SDK for iPhone and are ready to start compiling iPhone applications. We'll explain how to use it in the next section.