Articles

Running Hello World Locally (Xcode & Terminal)

  • Learn the basics of Swift syntax and variables and build simple programs in this introduction to the Swift programming language.
    • Beginner Friendly.
      1 hour
  • Learn how to build iOS applications with Swift and SwiftUI and publish them to Apples' App Store.
    • Includes 7 Courses
    • With Certificate
    • Beginner Friendly.
      13 hours

What is Xcode?

Xcode is an IDE, Integrated Development Environment, containing a suite of software development tools developed by Apple for developing software for iOS, watchOS, macOS, iPadOS, and tvOS.

It was first released in 2003 and the latest stable release is version 11.0 and is available via the Mac App Store for download.

Xcode Screenshot

Typically Swift source code files are given the suffix:

  • .swift (ex: Hello.swift)

Running Locally using Terminal:

Sometimes it is more convenient to run Swift code in the terminal.

On a Mac, it’s called the Terminal and looks like this: Black background with a simple white terminal prompt symbol consisting of a greater-than sign and a dash, resembling '>-'. On Windows, it’s called the Command Prompt and looks like this: Black background with white text showing the Windows command prompt symbol 'C:\'.

Let’s see how we can do it in a macOS terminal:

$ swift --version

Compile:

$ swiftc Hello.swift

swiftc and the source file name.

Execute:

$ ./Hello

./ and the executable file name.


Compiling (xkcd)

xkcd: Compiling

Codecademy Team

'The Codecademy Team, composed of experienced educators and tech experts, is dedicated to making tech skills accessible to all. We empower learners worldwide with expert-reviewed content that develops and enhances the technical skills needed to advance and succeed in their careers.'

Meet the full team

Learn more on Codecademy

  • Learn the basics of Swift syntax and variables and build simple programs in this introduction to the Swift programming language.
    • Beginner Friendly.
      1 hour
  • Learn how to build iOS applications with Swift and SwiftUI and publish them to Apples' App Store.
    • Includes 7 Courses
    • With Certificate
    • Beginner Friendly.
      13 hours
  • A powerful programming language developed by Apple for iOS, macOS, and more.
    • Beginner Friendly.
      12 hours