Getting Started with the iPhone SDK

Jul 5 2010 by Amber Weinberg | 21 Comments

Getting Started with the iPhone SDK

This article is a general overview of making iPhone apps using the iPhone software development kit (SDK).

In order to start making your own iPhone apps, you’ll need to sign up for a free Apple Developer account and download the iPhone SDK.

What’s the iPhone SDK?

Apple has bundled a ton of great resources into a mega 2GB download that contains help files, documents and three very important apps: Xcode, Interface Builder and iPhone Simulator. All of these apps also work for the creation of iPad apps.

Let’s take a quick look at the three apps and see what they do.

Xcode

Xcode

Xcode is the integrated development environment (IDE) of the SDK and the main app you’ll be using when creating your apps.

It’s similar in interface to the popular Coda IDE for website development, but it’s much, much more powerful since it’s built to specifically handle Objective-C (the programming language used on Mac OS X and iOS) and Cocoa (Apple’s development framework).

When coding, you’ll find that Xcode offers code completion and hints that can greatly speed up your development time. Typing in 3 or 4 characters will often result in Xcode choosing the right method or option you’re trying to type and even remembers classes and object names you’ve created. Xcode also comes with documentation that can be accessed by pressing the Option key and doubling-clicking on the methods.

Xcode offers different project types depending on the kind of app you’re planning on building. Projects are the files and resources that make up your app and they’re bundled together by the SDK. Most of them never need to be edited, but are required for the app to run.

Starting a New Project in Xcode

If you go to File > New Project (Shift + Command + N), you’ll see the different project types that Xcode offers.

The View-Based Application option is probably the most common type for beginners. Select it, hit the Choose button and then give your project a name and a place to save it.

Choosing a project type allows Xcode to build and link the core files and resources together.

The left-hand column is called the Groups & Files pane. The Groups & Files pane contains all of the files and resources that were created when you selected the View-Based Application project type.

If you expand the tree underneath the name of your project (using the triangle), you’ll see that there are five folders contained underneath it. Let’s go over what these folders are.

Classes folder: Most of the time, you’ll be using the files contained within the Classes folder. The Classes folder simply contains all of the Objective-C classes you’ll be creating. The two most important files you’ll be editing are called your_project_name_ViewController.h and your_project_name_ViewController.m.

Other Sources folder: This folder contains all of the classes that aren’t in Objective-C.

Resources folder: The Resources folder contains all the files, images, sound files, movies, etc. that belong to your app. Any resource you want to use within your app has to be placed here while in test mode unless you’re using the iPhoto or Address Book APIs. This folder also contains your your_project_name_ViewController.xib file. Doubling-clicking this file opens up Interface Builder, allowing you to begin seeing what the user sees (more on this topic later down the article).

Frameworks folder: The Frameworks folder can contain both code and resources and common frameworks that are already included.

Products folder: The Products folder contains the actual app that is produced when you compile your project. If you expand this folder without having compiled your project, you’ll see you_project_name.app in red because it won’t exist.

Xcode’s Detail Pane and Editor Pane

In the right-hand column, you’ll see we have two different panes. The top pane is called the Detail pane and it shows you information about the files inside Groups & Files. You probably won’t use this pane very often, so you can minimize it some by clicking and dragging up the bottom portion.

The pane beneath the Detail pane is the Editor pane. This is where all your coding happens! If you click one of the files under your Classes folder in the Groups & Files pane, the file will appear in the Editor where you can then work on it.

Now that we’ve taken a tour of Xcode, let’s check out the second most important app: Interface Builder.

Interface Builder

Interface Builder

One of the coolest things about iPhone development is that making the apps requires a lot less code than you would think, thanks to the Interface Builder.

Open Interface Builder by double-clicking the your_project_nameViewController.xib file under the Resources folder in the Groups & Files pane of Xcode. Interface Builder opens as a series of four windows.

You can think of the Interface Builder as sort of a visual WYSIWYG for the iPhone, but it’s much more than that. It never produces ugly code, and in fact, you’ll never see the code. It’s also built with Apple’s design guidelines and grids to ensure you’re app doesn’t come out as the ugly stepchild!

The Library window gives you all the views and controls that you can simply drag and drop onto your interface (the module marked as "Window").

The Inspector window is where all of your settings and controls lie. This window actually contains four different views that you can access by clicking one of the top icons or by pressing Command + 1-4 to access each view.

Attributes: The first window shows the object’s attributes. You can change fonts, colors and sizes from this window.

Connections: shows the available ways you can connect the object to an action. For example, buttons have a ton of connections such as Touch Up Inside and Touch Drag Outside that all correspond to how a user may interact with your object.

Size: The Size window allows you to adjust the size, alignment and positioning of the object on the window. This view will be most helpful when dealing with repositioning of the app due to horizontal and vertical views (rotation of the iPhone).

Identity: This view is less used than the others but it gives you the ability to set class names, as well as what the object is and does.

Other Important Features of Interface Builder

The smaller window marked your_project_nameViewController.xib contains icons that represent each Objective-C class that was created when you started a new project — with the exception of the first two icons.

The first icon — File’s Owner — represents the object that loaded your .xib file (which is commonly referred to as a "nib" file — confusing, I know).

The First Responder icon represents the object or control the user is interacting with — for example, a text field or a button.

The coolest thing about Interface Builder is how it connects to Xcode. After you’ve coded your objects and actions in Xcode, you’ll switch over to Interface Builder to create what the user actually sees.

Then, to connect the objects in Interface Builder to what you’ve coded, you simply Command + click and drag from the File’s Owner icon in the Untitled Window to the object to assign it. You can also do the same to assign an action to the button.

iPhone Simulator

The iPhone Simulator does just what it promises — it gives you a realistic simulator of how your app will look and work on a real iPhone. It even allows you to hit the Home button to view the app’s icon.

You can also use the simulator to view apps on the iPad and even to open Safari and view websites on.

Testing on a Real iPhone

If you want to use a real iPhone to test on, you’ll need to pay Apple’s Mac Developer Program membership fee. An Apple Developer account is free, but in order to put your apps on your own iPhone or sell it in the Apple Store, you must sign up and pay $99 for the privilege.

Further Reading on iPhone Apps

Now that you’ve taken a tour of the SDK, it’s time to start building apps! I’ve been using a ton of resources to help me learn more about the process, so I’d thought I’d share a few of my favorites with you here.

Beginning iPhone 3 Development by Dave Mark

This is an excellent book for beginners. The apps work (no code errors) and it’s easy to follow along even if you have no Objective-C experience.

OnMacDevelopment

This is a video podcast offering tutorials and topics on Mac and iPhone development.

MobileTuts

I tend to skim through these posts quickly, but they often have interesting topics.

Rework and Getting Real by 37signals

While not specifically about iPhone apps, these two books can inspire you in the business side of making apps, launching your projects well, and development practices.

Have you used the iPhone SDK before? What are your thoughts on it? Do you have any excellent beginner resources to share?

Related Content

About the Author

Amber Weinberg is a freelancer with over 10 years of experience. She’s the founder of codesnipp.it, a social site for developers. She specializes in clean, semantic and valid 1.0 Strict XHTML, CSS and WordPress development. She also writes a web development blog on her portfolio site at www.amberweinberg.com.

21 Comments

Erik

July 5th, 2010

You’ll need a Mac as well?

Patrik Björklund

July 5th, 2010

Thanks for the OnMacDevelopment tip! Im always looking for good podcasts on iphone development :)

Amber Weinberg

July 5th, 2010

@Erik Yes you have to have a Mac to develop any Mac related apps.

@Patrick no problem ^_^ I recently found a stash of great podcasts and books, I have about 79 unlistened to podcasts waiting for me ;)

Simon Owen Design

July 5th, 2010

@Erik I’ve heard of people using a ‘hackintosh’ and various other software on PC so I believe it’s possible, but haven’t done it myself. Think you’d find it easier on a mac.

Young

July 5th, 2010

sweet now all i need is to be able to afford a mac…

hollsk

July 5th, 2010

@Erik – yeah, you’ll need a Mac as well. You may be able to get by with a Hackintosh but from what I’ve read it’s quite a lot of hassle getting it to work with any kind of stability. The SDK iPhone emulator is also imperfect so you can add a meatspace iPhone to your shopping list while you’re at it.

The barrier to entry for Android development is much lower than iPhone and the Android OS is is considered by a lot of devs to be superior also. If any devs want to get into mobile development but aren’t interested in buying all the kit Apple expects you to buy then Android is a great place to start.

Jon K.

July 5th, 2010

To become an Apple developer, you have to pay $99.

Jon K.

July 5th, 2010

Actually, to clarify, you need to pay $99 for the Dev program, which is essential.

macpaul

July 6th, 2010

I’ve always wondered why you can’t test apps on your own iPhone without the full membership

Siddanth

July 6th, 2010

Even i had the same question as Erik i have some awesome books too just wanted to know as i don own a mac with me

Tom

July 6th, 2010

You can do it on a PC but it is a bit of a fiddle you can’t publish apps from pc either (as far as I know). It’s called apple monopoly!

FaviconService

July 6th, 2010

never forget that every iPhone app needs representative icon, so you’ll need to find background templates and use stock graphics aplied to it or hire professional designer.

Amber Weinberg

July 6th, 2010

@Jon that is incorrect. You can be an Apple developer to do your own apps for free, however, to sell them in the app store or put them on an actual iPhone, you then need to pay $99. The dev programs are free.

Eric Rowell

July 6th, 2010

Thanks Amber for the article!

Does anyone have any experience with marketing iphone apps? Does the Apple store do a good job giving newer apps visibility?

Jacob Gube

July 6th, 2010

@Eric Rowell: I’d love to know some tips to this as well. I presume it would be the same general process as marketing and promoting a web app or website/blog, but I’m sure there are a few subtle, nuanced differences.

Kevin Le

July 7th, 2010

If a developer is going to use MonoTouch, would he/she also be required to register?

Bilal Aslam

July 9th, 2010

For a small developer or a student (like me) it is very difficult to get into iOS development. You have to use a Mac which is far more expensive then a windows based PC. Also there is a 99$ fee if I want to test an app on real phone.

Stella

July 10th, 2010

I think buying Mini Mac would be the best legal solution to be able to build native apps for the iPhone/iPad..
For developing on a Windows environment there is Appcelerator Titanium, PhoneGap or the Adobe Packager(CS5 and AIR), which works really great.
There is also a nice guide pointing to some useful resources on ipad app development, that might come in handy..

dukeduke

July 12th, 2010

Hi guys, I recently lost my job as a mech engineer and decided I want to learn to program for the iphone. I have never programmed in Objective C before, but have had experience with the old programming language of Pascal, Fortran and stuff. Where can I find info to help me step-by-step to program for the iphone. Also, do I need a mac or can I use the PC to program? Any books you can recommend? Please let me know.. Thanks..

Harry

August 16th, 2010

There are various SDKs that can be used in Windows to develop on the iPhone. Do some searches. I’ve never tried them myself though. A hackintosh (illegal) is also possible – it’s essentially dual-booting Mac OS onto a normal PC. It can also be fairly difficult. Thirdly, there is the possibility of using a Virtual Machine within Windows. It’s clean and easy, but I think it’s also illegal. And finally, get yourself a Mac. Mac mini is cheapest.

Ryan

April 11th, 2011

I was wondering if you can run these dev kits if you run Mac OS on a virtual machine. I assume this will work, but I thought I would ask to see if anyone has tried this and has had it fail.

Leave a Comment

Subscribe to the comments on this article.

Mobify empowers marketers and developers to create amazing mobile web experiences.

Mobify