In this tutorial, you will learn to write a program to print “Hello, World!” in Swift.

Swift is the advanced programming language that was designed to overcome the several challenges of the versatile Apple programming language Objective C. It was presented on 2 June 2014 by Apple Inc.

A Hello World is a basic program that prints Hello, World! on the screen. This program is frequently used to introduce a new programming language to beginners.

Let’s explore how to create “Hello, World!” program in Swift.

Swift “Hello, World!” Program

// Swift "Hello, World!" Program

print("Hello, World!") 


Hello, World!

Note: If you need to run this program on your computer, ensure that Swift is appropriately installed. To learn more about setting up Swift on your computer, visit Getting Started with Swift.

How Swift “Hello, World!” Program Works?

Here are the various segments of the Hello World program in Swift:

1. Swift Comment

// Swift "Hello, World!" Program

We use two slashes // to write comments in Swift.

Comments are hints that we can add to our program to make our code more understandable.. They are intended for individuals reading the code. To learn more, visit Swift Comments.

2. print Statement

print("Hello, World!")

The code above shows the text Hello, World! on your screen.

Congrats! You just wrote your first program in Swift.

Next we’ll learn about variables, constants, and literals in Swift.

Thanks for reading! We hope you found this tutorial helpful and we would love to hear your feedback in the Comments section below. And show us what you’ve learned by sharing your photos and creative projects with us.