Getting ready for the SDK (iOS 4)

The iOS software development kit (SDK) is a suite of programs available in one gargantuan (at the time of writing over 4 GB) download from Apple. It gives you the tools you need to program (Xcode—Xcode 4 is the version of the iDE used in this topic), debug (Instruments), and test (Simulator) your iPhone, iPod Touch, and iPad code.

NOTE You must have an Intel-based Apple Macintosh running Mac OS X 10.6.5 or higher to use the SDK.

Installing the SDK

To obtain the SDK, download it from Apple’s iOS Dev Center, which at the time of this writing is accessible at You’ll need to register as an iOS Developer in order to get there, but it’s a fairly painless process. Note that you can also use this site to access Apple documentation and sample source code.

NOTE Xcode 4 is a free download for all members of the iOS Developer Program, which costs US$99 per year. If you’re not an iOS Developer Program member, you can purchase Xcode 4 from the Mac App Store for US$4.99 or download Xcode 3 for free.


To see the full API documentation as well as sample code, visit It contains a few introductory papers, of which we think the best are "iOS Overview" and "Learning Objective-C: A Primer," plus the complete class and protocol references for the SDK.

As we’ll discuss in the next topic, you can also access all of these docs from inside Xcode. We usually find Xcode a better interface because it allows you to click through from your source code to your local documents. Nonetheless, the website is a great source of information when you don’t have Xcode handy.

Because they tend to be updated relatively frequently, we’ve been constantly aware of Apple’s documents while writing this topic, and we’ve done our best to ensure that what we include complements Apple’s information. We’ll continue to provide you with introductions to topics and to point you toward the references when there’s a need for in-depth information.

After you’ve downloaded the SDK, you’ll find that it leaves a disk image sitting on your hard drive. Double-click it to mount the disk image, and then double-click Xcode and iOS SDK in the folder that pops up to start the installation process (as shown in figure 1.2).

This will bring you through the entire install process, which will probably take 20-40 minutes. You’ll also get a few licensing agreements that you need to sign off on, including the iPhone Licensing Agreement, which lists some restrictions on what you’ll be able to build for the iOS-based devices.

Warning: installation dangers

The default installation of Xcode and iOS SDK will replace any existing Apple development tools you have. You’ll still be able to do regular Apple development, but you’ll be working with a slightly more bleeding-edge development environment.


Although Apple is making the iOS SDK widely available for public programming, the company has placed some restrictions on what you can do with it. We expect these restrictions to change as the SDK program evolves, but what follows are some of the limitations at the time of this writing.

Among the most notable technical restrictions: you can’t use the code to create plug-ins, nor can you use it to download non-SDK code. It was the latter that apparently spoiled Sun’s original plans to port Java over to the iPhone. You also can use only Apple’s published APIs. In addition, there are numerous privacy-related restrictions, the most important of which is that you can’t log the user’s location without permission. Finally, Apple has some specific application restrictions, including restrictions on apps that incorporate pornography or other objectionable content.

Double-clicking Xcode and iOS SDK starts your installation.

Figure 1.2 Double-clicking Xcode and iOS SDK starts your installation.

In order for your program to run on iPhones and iPads, you’ll need an Apple certificate, and Apple maintains the right to refuse your cert if it doesn’t like what you’re doing. If you’re planning to write anything that might be questionable, you should probably check whether Apple is likely to approve it first. For example, the most-used third-party software package that isn’t available natively is Flash. This topic is going to cover how to develop an app on iPhone or iPad with the iOS SDK. But there’s another way to deliver an application to iPhone or iPad: using HTML5+JavaScript for web apps. We won’t cover web application development in this topic.

When the SDK finishes installing, you’ll find it in the /Developer directory of your Mac system disk. Most of the programs appear in /Developer/Applications, which we suggest you make accessible using the Add to Sidebar feature in the Finder. The iOS Simulator is located separately at /Developer/Platforms/iPhoneSimulator.platform/ Developer/Applications. Because this is off on its own, you may want to add it to your Dock.

You now have everything you need to program for the iOS devices, but you won’t be able to release iPhone or iPad programs on your own—that takes a special certificate from Apple. See Topic C for complete information on this process, which is critical for moving your programs from the Simulator onto a real device. The Simulator turns out to be one of several programs you’ve installed, each of which can be useful in SDK programming.

The anatomy of the SDK

Xcode, Instruments, and Dashcode were all available as part of the development library of Mac OS X before the iPhone came along. Many of these programs are expanded and revised for use on the iPhone, so we’ve opted to briefly summarize them all, in decreasing order of importance to an SDK developer:

■ Xcode 4 is the core of the SDK’s integrated development environment (IDE). It’s where you’ll set up projects, write code in a text editor, compile code, and generally manage your applications. It supports code written in Objective-C (a superset of C that we’ll cover in more depth in the next topic) and can also parse C++ code. Interface Builder is now a part of Xcode 4, and it allows you to put together the graphical elements of your program, including windows and menus, via a quick, reliable method. You’ll learn the specifics of how to use Xcode 4 in topics 3 and 4.

■ iOS Simulator allows you to view an iPhone or iPad screen on your desktop. It’s a great help for debugging web pages. It’s an even bigger help when you’re working on native apps, because you don’t have to get your code signed by Apple to test it out.

■ Instruments is a program that allows you to dynamically debug, profile, and trace your program. If you were creating web apps, we would have to point you to a slew of browsers, add-ons, and remote websites to do this sort of work; but for your native apps, that’s all incorporated into this one package.

■ Dashcode is listed here only for the sake of completeness because it’s part of the /Developer area. It’s a graphical development environment that’s used to create web-based programs incorporating HTML, CSS, and JavaScript. Dashcode is used when developing for the web; you won’t use it with the iOS SDK.


If you’d prefer to immediately dive into your first program, HelloWorld, head to topic 3. You can then pop back here to see what it all means.

Figure 1.3 shows the most important developer tools. In addition to the visible tools that you’ve downloaded into /Developer, you’ve also downloaded the entire set of iOS frameworks: a huge collection of header files and source code—all written in Objective-C—that will greatly simplify your programming experience. In the next topic, we’ll look at Objective-C, the SDK’s programming language. Rather than jumping straight into your first program, we instead want to touch on these founda-tional topics. In the next section, we’ll examine some of the basics of iOS.

The SDK includes Xcode (top) and two instances of the iOS Simulator, running in iPad mode (bottom left) and iPhone mode (right).

Figure 1.3 The SDK includes Xcode (top) and two instances of the iOS Simulator, running in iPad mode (bottom left) and iPhone mode (right).

Next post:

Previous post: