After you’ve set up your iOS SDK toolset, the very next thing you should do is make sure that you can get make a simple iOS application that works.
The main reason that we want to do is is to make sure that your Xcode setup is working properly. Also, it just helps you with the confidence game. This is why everything programming training program has a so-called Hello World app.
The first thing that you need to do is open the Xcode application. Of course, you should have already followed the steps we outlined before in this guide to set up your iOS SDK toolset.
Once Xcode has been set up you can open up the application by going to Applications directory in Finder and then double-clicking on the Xcode icon.
When Xcode is done launching and ready for you, the Xcode menu bar will appear in the top of your Mac’s screen.
Create New Project
Xcode organizes our work based on this idea of projects. Projects are collections of material like source code, storyboards, images, sounds, databases and movies that will ultimately be used to generate an application.
To create a new project in Xcode, go to the Xcode menu bar and choose Xcode > File > New > Project….
A dialog will pop up here. Choose iOS > Application > Single View Application.
Another dialog box will pop up here. You can enter in a name for your Xcode project along with any other identifying information. Make sure to pick Use Storyboards and Use Automatic Reference Counting.
Click Next and then click Create.
You’ll be left with a screen that looks something like this:
This is the main area that will use to work with your Xcode project.
Click the Run button in the top left area of your Xcode project. In a few seconds you will see an iPhone with a blank screen running in your Mac. This is the iOS simulator running the iOS application that was created based on your Xcode project settings.
In the most basic sense, that’s all there is to it. Of course, this is not all that interesting. So, let’s make it a little more interesting by using a Storyboard to say Hello World.
In the left hand side of your Xcode project, locate the file named MainStoryboard.storyboard and click on it. You will see an editor show up that is displaying what looks like a blank user interface. This is your app’s storyboard. Storyboards are used to manage most aspects of an application’s user interface. This is what you should be seeing:
Now locate the Object Library. This is the widget in the lower right hand corner of your Xcode project screen. It will be a list of objects that start with an object named View Controller. If you don’t see this, click on the third tab.
Look through the Object Library until you locate the Label object. See the screen below to get an idea of what I’m talking about.
Click and hold the label object then drag the label object into the blank screen on your storyboard. Try to stick the label in the middle of the screen.
Once you are satisfied that the label is securely in place, double click on the label in the storyboard. Type in the worlds Hello World.
You should see something like this in your Xcode project storyboard:
Run and Test Your App
Click the Run button. Xcode will turn your project into an app and then run the app on the iOS simulator. This time you should see the Hello World text appear in the iOS Simulator like this:
Really, That’s It
And so there you have it… Apple has done lots of the work for us already and that’s why this process is so easy. Many other things we’ll be doing with iOS apps are similar – you’ll find many tools, patterns and best practices already set up for you ready to be used.