LinuxCommandLibrary

swift

Swift language compiler and package manager

TLDR

Start REPL

$ swift
copy
Run script
$ swift [script.swift]
copy
Build package
$ swift build
copy
Build release
$ swift build -c release
copy
Run package
$ swift run
copy
Run tests
$ swift test
copy
Create new package
$ swift package init --type [executable]
copy
Show dependencies
$ swift package show-dependencies
copy

SYNOPSIS

swift [build] [run] [test] [package] [options] [files]

DESCRIPTION

swift is the Swift programming language compiler and package manager. It builds, runs, and tests Swift applications.
The REPL provides interactive Swift execution. It's useful for experimentation and learning.
Swift Package Manager handles dependencies and builds. Package.swift defines targets, dependencies, and products.
Debug builds are fast to compile with debugging support. Release builds optimize for performance.
Testing integrates XCTest framework. Tests run with swift test, supporting parallel execution.
Cross-platform support includes Linux and Windows beyond Apple platforms. Server-side Swift is a common use case.

PARAMETERS

build

Build the package.
run [TARGET]
Build and run.
test
Run tests.
package init
Create new package.
package update
Update dependencies.
package resolve
Resolve dependencies.
-c CONFIG
Build configuration (debug, release).
-Xswiftc FLAG
Pass flag to compiler.
--version
Show version.
--help
Show help.

CAVEATS

Full functionality on macOS. Linux support is good but some Apple frameworks unavailable. Windows support is newer.

HISTORY

Swift was announced by Apple at WWDC 2014, developed by Chris Lattner and others. It was open-sourced in 2015. Swift has evolved significantly, with Swift 6 introducing strict concurrency.

SEE ALSO

swiftc(1), xcodebuild(1), vapor(1)

> TERMINAL_GEAR

Curated for the Linux community

Copied to clipboard

> TERMINAL_GEAR

Curated for the Linux community