Swift 6 cheatsheet

Swift 6: Tooling

5 common Swift 6 tasks.

Check the Swift version

Print the installed Swift toolchain version.

swift --version

Create a package

Create a new command-line project with Swift Package Manager.

swift package init --type executable --name MyTool

Build and run

Build the package, run it, and run its tests.

swift build
swift run
swift test

Run a script file

Run a Swift source file without building a project.

swift script.swift

Add a dependency

Declare a package in Package.swift.

.package(url: "https://github.com/apple/swift-argument-parser", from: "1.5.0")

Was this page helpful?