swift
Manage OpenStack Swift object storage
TLDR
Start a REPL (interactive shell)
Execute a program
Start a new project with the package manager
Generate an Xcode project file
Update dependencies
Compile project for release
SYNOPSIS
swift subcommand [options]
swift file.swift [arguments...]
swift --version
swift --help [subcommand]
Common Subcommands:
swift build [options]
swift run [options] [target [arguments...]]
swift test [options]
swift package subcommand [options]
PARAMETERS
--version
Prints the Swift compiler version and associated toolchain information.
--help, -h
Displays general help or specific help for a given subcommand.
--verbose
Enables verbose output, showing detailed progress and commands being executed.
--configuration config
Specifies the build configuration (e.g., debug or release) for building or running targets. Common for build, run, test.
--build-path path
Specifies the custom path for the build products. Common for build.
--triple target-triple
Specifies the target triple for cross-compilation.
--skip-build
Skips the build phase when running or testing, assuming artifacts are already built. Common for run, test.
--enable-test-discovery
Enables automatic test discovery for Swift Package Manager tests. Common for test.
DESCRIPTION
The swift command is the primary command-line interface for interacting with the Swift programming language toolchain. It provides a versatile set of subcommands for building, running, testing, and managing Swift packages, making it an essential tool for Swift developers on Linux. Users can compile Swift source code into executables or libraries, execute Swift scripts directly, and manage dependencies for complex projects using the integrated Swift Package Manager (SPM). The command facilitates a smooth development workflow, from project initialization to deployment, by abstracting complex build processes and offering a unified interface for various development tasks. Its cross-platform nature allows Swift applications to be developed and deployed consistently across different operating systems, including Linux, macOS, and Windows.
CAVEATS
The swift command is not a standard, pre-installed Linux utility; it requires the Swift toolchain to be manually installed or set up on the system. Its primary utility is for Swift language development, and it does not perform general system administration tasks like most other core Linux commands. Functionality heavily depends on the installed Swift version and associated libraries.
<B>SUBCOMMANDS STRUCTURE</B>
The swift command operates primarily through a subcommand model, where the first argument specifies the action to perform (e.g., build, run, test, package). Each subcommand may have its own set of specific options and arguments, allowing for granular control over different aspects of Swift development.
<B>SWIFT PACKAGE MANAGER (SPM)</B>
A significant part of the swift command's functionality is provided by the integrated Swift Package Manager. SPM is a tool for managing the distribution of Swift code, designed to make it easy to share code and automate its compilation. Commands like swift build, swift run, and swift test leverage SPM for dependency resolution and project configuration.
HISTORY
The Swift programming language was introduced by Apple in 2014, initially as a proprietary language for Apple platforms. In December 2015, Apple open-sourced Swift, including the compiler and core libraries, under the Apache 2.0 license. This move was pivotal, making Swift available on Linux and other non-Apple platforms. The swift command-line tool emerged as part of this open-source initiative, evolving to provide a unified interface for building, testing, and managing Swift projects across different operating systems. Its development has focused on enhancing cross-platform compatibility, improving the Swift Package Manager (SPM) for dependency management, and streamlining the developer experience outside of Xcode.
SEE ALSO
clang(1) - The Clang C, C++, and Objective-C compiler, often used as Swift's underlying compiler driver., gcc(1) - The GNU Compiler Collection, an alternative compiler suite., make(1) - A GNU tool for controlling the generation of executables and other non-source files of a program., git(1) - The popular distributed version control system, frequently used by Swift Package Manager for dependency resolution., xcodebuild(1) - (macOS only) Builds one or more targets in a project or workspace (analogous functionality on macOS).