Creating Hello World Using Swift

Creating Hello World Using Swift – is the first tutorial of our course. For building this tutorials we have used

  • Xcode 6
  • iOS 8
  • swift programming language

First let’s take a look at final app that we are about to build.



This will be a very simple app having one button “Say Hello”, when tapped ‘ll show the message. Thats it, no space science needed. It will also help you in getting familiar with the developing environment.


We assume that you already have Xcode. Just click on Xcode and you will see the following options on welcome screen.


Here we will choose “Create a new Xcode project”, we will also look at other option on this screen in later tutorials. Click on “Create a new Xcode project” and Xcode will display various project template.



Here We will choose “Single View Application” and press “Next”, you will be navigated to this screen:



Fill in the following options and simply proceed.

  • Product Name : HelloWorld – This will be the name of our app.
  • Organization Name : AppTuitions – you can use your own name or just as of now use mine.
  • Organization Identifier : com.apptuitions – This is used to create unique app identifier for your app. Its just the domain name written in the other way around.
  • Bundle Identifier : com.apptuitions.SimpleTable – As i said above this is the unique identifier for your app.
  • Language : Swift – We will be using swift as programming language for this tutorial.
  • Device : iPhone – Choose iPhone as off now. We will look into other options in later tutorials.
  • Use Core Data : Unchecked – Keep it Uncheck as of now we don’t need it. We will also  have a separate tutorial on this later on.

Tap on “Next” and Xcode will ask for the location where you want to save your app.



Now select a folder or create new and press “Create”. You will get the following screen.



Now, Select the “Main.storyboard” .



  1. Select Main.storyboard
  2.  Select view
  3. Select “iPhone 4 inch” from dropdown menu for size(We will explain this later on why we are doing this.)
  4. select “Portrait” from the dropdown menu for orientation.

The app is ready. Go press “Run” button on the top left corner of Xcode.



and you will get it running on simulator



Its blank, isn’t it? Don’t worry we just need little code snippet to make is say “Hello World”. :) Press “Stop” button to  terminate the app.




Now from the project navigator select the Main.storyboard .you will see the following empty view.



In the lower portion of utility area, you will find different view components. from here we have to drag and drop the “Button” element into our empty view as described in below image.



Now, rename button’s title by double clicking on it. Here we will name it as “Say Hello”, you can name it whatever you like.



Lets Add Code To This Button

Now, Press “Show the assistant editor” button in the upper right corner of utility area.



And you on following screen.



Adding An Action To The Button

 Ok, going good so far. Now, press and hold Control key and select the Button and drag and drop into ViewController.swift class. The screen should look like this.


Now release the mouse click after drag and drop and set connection to “Action” and add method name as “buttonPressed”.


 and press “connect”.

 Now, you can see the function “buttonPressed” which will be triggered when user touches the button.

We are almost there

 Now add the following code to your “buttonPressed” function.

var alertView = UIAlertView()
alertView.title = "My first swift app!!"
alertView.message = "Hello World"

 and your ViewController.swift class and “buttonPressed” function will look like this.


THATS IT!! Go run your app and we are done with our first iOS Swift tutorial.

 Thanks for visiting. More tutorials will be added soon. Stay Tuned.