Hello World in Swift
You can create a “Hello World” project directly through the CLI using swift package
:
mkdir HelloWorld
cd HelloWorld
swift package init --type executable
This will produce several files:
Creating executable package: HelloWorld
Creating Package.swift
Creating .gitignore
Creating Sources/
Creating Sources/main.swift
The interesting content is in Sources/main.swift
:
// The Swift Programming Language
// https://docs.swift.org/swift-book
print("Hello, world!")
Then, just swift run
:
[5/5] Linking HelloWorld
Build complete! (0.60s)
Hello, world!