To get started with Swift, download the latest Xcode 6 version.

Once you have completed installation of Xcode 6, Follow the steps to create a command line application.

  1. Open Xcode.
  2. Select File -> New -> Project.
  3. In the new window that appears, Select Applications under OS X.
  4. Select command line application and press Next.
  5. Enter “Product Name” and press Next.
  6. Select location to save for your new project.

Now, you will find a main.swift file created for you. It contains a Hello World example by default as shown below.

import Foundation

println("Hello, World!")

When we run the above program, we will get the following result in the debug console.

Hello, World!

The println is used print any statement in a new line. As you can see, you don’t need a semi colon to terminate the statement. Use NSLog function, if you want to log in a special formatted log with time and application name.

Note to Objective-C developers

Remember !!!

Unlike NSLog, println don’t add the time during which the log statement was executed. For strings including the one used in NSLog(“string”), never use @ symbol as in Objective-C.