iOS Development in Xcode - Start Here

Thursday Apr 12th 2012 by Laurence Moroney

Perhaps you’ve always wanted to write that latest, greatest iOS application for iPhone, iPod or iPad, but didn’t know the best way to get started. Laurence Moroney shows you how to get started with iOS development.

Perhaps you've always wanted to write that latest, greatest iOS application for iPhone, iPod or iPad, but didn't know the best way to get started. You may have heard of Apple's development tools, languages and SDK's, but, not being familiar with a lot of them, didn't know a good onramp that you could use to get started.

This series is designed to do just that -- get you started, so you can navigate the masses of information about iOS development with a little more basic knowledge under your belt.

All you need is a Mac. Everything else is freely available.

Getting Xcode from the App Store

The first step, of course, is to get the tools that you'll use to build iOS applications. The standard tool for doing this natively is Xcode. You can get Xcode in the Mac App store, by searching for 'xcode'. You should see something like Figure 1.

Figure 1. Getting Xcode from the App Store
Figure 1. Getting Xcode from the App Store

Xcode is the first listing here, the blue schematic with a hammer over it. You'll get very familiar with this icon in time! Select it and install Xcode directly from the App Store. It's a big download, so it should take a while.

Running Xcode for the First Time.

When you first run Xcode you'll see the 'Welcome to Xcode' splash screen, which gives you a number of options, including creating a new Xcode project, connecting to a repository, etc. You can see this in Figure 2.

Figure 2. Welcome to Xcode Screen
Figure 2. Welcome to Xcode Screen

To create your first Xcode iOS application, you should select the 'Create a new Xcode project' option at the top.

Understanding Project Types and Creating your First Project.

When you create your first project, you'll see that Xcode can be used to create either iOS or Mac OS X applications. See Figure 3. For iOS you can build Applications, Frameworks and Libraries, or Other types. By default 'Other' just has a template for an empty application, but various add-ons to Xcode give new templates here.

Creating an iOS Project
Figure 3. Creating an iOS Project

To get started, select the 'Single View Application' type as shown in Figure 3 and select 'Next'.

You'll then be asked to give your application a name and an identifier. The identifier is a reverse domain name style, so, I use tv.netnavi, where my website is at

The device family setting should be 'iPhone' for now, and not 'iPad' or 'Universal'. Also make sure you have 'Use Automatic Reference Counting' checked. This makes coding much simpler for beginners. See Figure 4.

Project Options
Figure 4. Project Options

Next you'll be asked to pick a location where you'll store the project, and the environment will launch, with all the code needed to run your app.

Exploring the Code.

Xcode uses Objective-C which uses two files for every class. A Header file, with the .h extension, includes all the declarations for variables and functions used within the file, and an Implementation file, with the .m extension, which contains all your code. Additionally, user interface definition files can sometimes be used, though in this series you won't be using them, and they bear the .xib (for Xcode Interface Builder) extension.

You'll see that the template has provided two classes for you called 'AppDelegate' and 'ViewController'. Each of these has corresponding .h and .m files, and the ViewController also has a .xib file.

The AppDelegate is the entry point to your application from the operating system. It handles startup, shutdown, managing the launch window and more.

The ViewController is your view into the application. Typical apps have lots of view controllers, but because this is a single view app, there is only 1. You will edit this to change your user interface.

To make a quick 'Hello World', open the ViewController.m file. You'll find in it, a function called 'viewDidLoad', which currently looks like this:

viewDidLoad Function
viewDidLoad Function

Edit it to include a UILabel control, and then add that UILabel control to the view, like this:

UILabel control
UILabel control

This creates a new instance of a UILabel control, which as its name suggests is used as a Label. It initializes it within a rectangle at (x,y) co-ordinates of (0,100) with a width of 320 and a height of 40. It then sets the text to “Hello World”, and adds the label to the current view. iOS renders views, so when it renders the current view, it will also render the label.

When you run the app, you'll see it in the iPhone simulator as you can see in Figure 5.

Running 'Hello World' in the iPhone simulator
Figure 5. Running 'Hello World' in the iPhone simulator

And that's it, you've just built and run your first iOS application, albeit a very simple one. In future articles, you'll learn how to build on this.

Mobile Site | Full Site
Copyright 2017 © QuinStreet Inc. All Rights Reserved