Running Hello World Locally (Xcode & Terminal)
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.
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 the Mac, it’s called the Terminal. On Windows, it’s called the Command Prompt.

Let’s see how we can do it in macOS terminal:
$ swift --version
Compile:
$ swiftc Hello.swift
swiftc
and the source file name.
Execute:
$ ./Hello
./
and the executable file name.
Compiling (xkcd)
'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 teamRelated articles
- Article
Installing and Setting up Xcode
Learn how to install and set up Xcode 12 or later on your local machine. - Article
Compile & Execute
Run your Hello World C++ program locally using the Terminal, Command Prompt, or Visual Studio Code. - Article
Which IDE Should You Use for Mobile App Development?
Learn how an IDE (Integrated Development Environment) can make you more effective as a programmer and how to get started using one.
Learn more on Codecademy
- Free course
Learn Swift: Introduction
Learn the basics of Swift syntax and variables and build simple programs in this introduction to the Swift programming language.Beginner Friendly1 hour - Skill path
Build iOS Apps with SwiftUI
Learn how to build iOS applications with Swift and SwiftUI and publish them to Apples' App Store.Includes 7 CoursesWith CertificateBeginner Friendly13 hours - Free course
Learn Swift
A powerful programming language developed by Apple for iOS, macOS, and more.Beginner Friendly12 hours