Creating a new project

Now that you’ve got Xcode up and running, it’s time to create your first project. As is customary, we will be creating the “Hello World” App as our first app.


Open Xcode

Go ahead and select File > New Project inside Xcode. A dialog box will appear asking you to choose from many templates that you can choose for your application. Templates follow a certain design paradigm, meaning the underlying navigation and/or structure of the app is already in place for you. This means you don’t have to worry about how the application will function just yet.


Different project types

Master-Detail Application
This template uses the parent-child interface and allows the developer to create an application with multiple levels. The iOS Contacts app is a good example of a Master-Detail application. The main page (master) holds the key information, the person’s name. If the user wants to get more information about the person, they tap on it (drill down) and a new page appears with address, phone number and more.


Page-Based Application
A page based application is designed for content that needs be presented in a page-by-page manner.


Single View Application
This is one of the most used templates and it’s just a simple, single view application. Nothing is added and the developer is expected to add navigation and other items.


Tabbed Application
This is a common application template that places a number of buttons on the bottom toolbar of the application. The user can tap any of these buttons to navigate within the application.


A starting point for game development.

The Single View Application
Since this is our first project, we don’t need anything fancy. Go ahead and choose “Single View Application” and press the Next button.

  • Product Name: This is the name of your app
  • Organization Name: Your name or company name
  • Organization Identifier: com.YourCompanyName
  • Bundle Identifier: created automatically
  • Language: Swift
  • Devices: iPhone
  • Uncheck the remaining boxes (if any)


A  note about the organization identifier

The organization identifier is a unique name that identifies your company or name.  Apple recommends using a reverse domain name service notation for this field.  If you aren’t sure what to use, just enter “com.yourname”, without quotation marks.

Once you have filled in the information, click the next button, select (or create) a new directory specifically for this project, then select Create.



A brief Xcode walk-through

  1. Navigator – Here you can switch between your project’s files.
  2. Editor – Here you can add/edit code inside the files.  Ours may look a little difference since we use a black theme for our editor window (configurable via the Settings panel).
  3. Start – This starts the application inside the specified device (#5)
  4. Stop – This terminates the application
  5. Active Scheme – Select a simulator (runs on your computer) or an actual iOS device you have plugged in. This is where the application will run.
  6. Status – Gives you information about the status of the app.
  7. Hide/Show – These buttons allow you to hide/show elements of the Xcode user interface.


Adding some code

Now that we have our project created, lets add some code!

Tap the “ViewController.swift” file if it is not already selected and add your cursor to the end of the “super.viewDidLoad()” line.  Press enter and add the following:

print("Hello World")

The entire viewDidLoad method should look like this:

override func viewDidLoad() {
        print("Hello World")
        // Do any additional setup after loading the view, typically from a nib.

The method “print” will simply print the text that is between the parenthesis to the console. The console is a text window inside Xcode used for “listening” to the output of the app.

Running your code

Now lets run your code! Ensure that you have a simulator selected (#5 from the previous screenshot) and press the Play button on the top toolbar.

It might take a minute, but eventually an iPhone looking screen will appear. That’s it, you’ve created and ran your first iPhone project! What a minute. You may be asking yourself where is the code that you typed in? Take a look at the bottom portion of the Xcode interface (not the iPhone simulator), you should have a new little window showing you “Hello World” in text.

If you don’t see the console at the bottom, you can make sure it’s enabled by pressing the console button in the top toolbar (indicated by the middle icon on #7, in the screenshot above).


Going forward

Congratulations, you’ve created a simple project using Apple’s Xcode and new programming language Swift! We recommend that you explore Xcode a bit more to get a feel for the application. If this helped you or you need additional help, please leave a comment below.