iOS Development Tutorial: Creating Your First iOS App in Less Than 1 Hour

iosdevelopmenttutorialThe iOS is the biggest money making opportunity for developers since the glory days of Windows in the 90s. Stories abound of part-time developers cashing in million dollar checks after a hit iOS app. Top developers like Rovio (of Angry Birds fame) and King (Candy Crush) generate millions of dollars in revenues each year. Some companies, such as Zynga, have even gone public based on the strength of their mobile revenues from iOS.

In other words: developing apps for iOS can be wildly lucrative. And the best part? You can get started making iOS apps with little to no prior coding experience, as this popular course will teach you how to make iPhone and iPad apps in under one hour with no programming.

In this iOS development tutorial, we’ll learn how to create a simple ‘Hello World’ iOS app in under an hour.

Getting Started: Download Xcode

Apple has made it extremely easy for developers to get started with iOS development, thanks to the Xcode software. This is the bread and butter for any iOS developer – a comprehensive set of tools and resources for creating complex apps. You can download Xcode from Apple’s website here. You can also do a search for ‘Xcode’ in your Mac app store.

[Note: Xcode runs only on Mac OS X. Which means Windows and Linux users among you will have to rush out to the nearest iStore and grab a MacBook Pro or iMac. Alternatively, ask a friend to loan you his/her machine.]

Xcode installs like any other Mac app, though the app itself is nearly 4GB in size.

Learn how to create iOS apps with no coding in this FREE course!

Creating a New Project

Follow these steps to create your first Xcode project:

  1. Open Xcode after installation.
  2. Go to File -> New -> Project. Here, you can choose from various pre-built templates, including Single View Application, OpenGL Game, Utility Application, Master-Detail Application and Tabbed Application.
  3. For this project, select ‘Single View Application’.
  4. Choose a name for your application. For this project, type in ‘First Project’.
  5. Under Class Prefix, type in ‘First Project’.
  6. Select the platform you want it to run on. You can choose iPhone, iPad, or both. For this project, we’ll stick to iPhone.
  7. Make sure that storyboards option is checked. Storyboards is basically a tool to create app mockups and user interfaces on the fly. It was included in iOS 5 and has become an indispensable tool for developers. Also ensure that Automatic Reference Counting is enabled.
  8. Click ‘Next’ and save the file in your chosen directory by clicking on ‘Create’ on the next screen.
  9. Leave every other field, including Company Identifier.

Congratulations, you’ve now created your first Xcode project! But this is just the beginning. The hard part – creating the actual code – comes next!

Creating the Code

Xcode should  now open your newly created project automatically. You’ll notice a few files under your project folder in the left hand pane. These files will be:

  • AppDelegate.h
  • AppDelegate.m
  • MainStoryboard.storyboard
  • ViewController.h
  • ViewController.m

ViewControlle and AppDelegate are somewhat similar in function but differ broadly in scope. ViewController.m basically controls one screen of an application, while AppDelegate.m controls the overall application. MainStoryboard.storyboard, meanwhile, controls the app UI.

For the purpose of this tutorial, we’ll do all our programming in ViewController.m and ViewController.h.

1. Open ViewController.h

2. Between @interface and @end, add the following code:

@property (strong)IBOutlet UILabel *label;

This controls the text used in the ‘Hello World’ app. You can select different properties for the text, including copy, nonatomic, retain, assign, a brief overview of which can be seen here.

3. Now open ViewController.m

4. After @implementation ViewController, add:

@synthesize label;

5. Below @implementation, you’ll notice a function, (void)viewDidLoad. Under this function, just before the ‘}’, add:

self.label.text = @”Hello World!”;

This creates a text label specified within inverted commas upon application load.

Altogether, your ViewController.m file should look like this now (not including the comments specified by ‘//’):

@import “ViewController.h”
@interface ViewController ()
@end
@implementation ViewController
@synthesize label;
- (void)viewDidLoad
{
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
        self.label.text = @”Hello World!”;
}
- (800L)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
        Return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
@end

That’s it! We’re done with the programming part. Now we have to connect the code with the interface.

Confused? Mark Lassoff’s popular iOS Code Development Camp will clear all your iOS programming doubts!

Connecting the Interface

In this part, we’ll use MainStoryboard.storyboard to create an interface for our app:

1. Open MainStoryboard.storyboard

2. Search for a label under ‘Objects’ section in the right pane. Drag and drop it onto the interface.

3. Here, you can resize the label to suit your requirements. You can also select the font from the right pane under ‘Attributes’. For now, leave the label size and font as it is.

4. Now open ViewController.h in the Assistant Editor

5. You’ll notice a little circle to the left of the @property line. Drag this circle and drop it onto the label created in MainStoryboard.storyboard.

That’s it! We’ve now connected our code to the interface. All that remains is to run the app.

Running the App

At the top of the Xcode window, you’ll find two buttons for ‘Play’ and ‘Stop’.

Choose the simulator of your choice (you can leave the simulator to default) and click on the ‘Play’ button. You should see a window resembling the iPhone on your screen. If you did everything right, this window should say ‘Hello World!’

Congratulations! You just created your very first iOS app! For learning how to create more complicated apps, refer to the comprehensive ‘Learn iOS Programming From Scratch‘ course.

What are your favorite beginner tips, tutorials and workarounds for iOS development? Share them with us in the comments below!