Hello, World is the First program that explains how to write a program, and compile and run the program in Swift.
Swift Hello World First Program
Hello World program contains three ports
Comments are a string of text about lines of code or swift files.
These are also ignored by the swift compiler.
It always starts with
//followed by comment text
import keyword used to import namespaces that contain variables, and functions into current code. The Foundation library is a basic library that provides a utility class in Swift to import
print is the output function that prints the string to the console.
Next, Open Visual Studio Editor and create a Hello. swift
Swift code extension is .swift
// Hello.swift // Hello World program in Swift import Foundation; print("Hello World W3schools.io!");
Compile and Run the Swift program
Compile the code using swiftc compiler
It compiles the code and creates an executable file
You can run the code using
In Linux or Mac