swift

Swift compiler

Subcommands

NameDescription
buildBuild sources into binary products
runBuild and run an executable product
testBuild and run tests
packagePerform operations on Swift packages

Options

NameDescription
--help, -h, -helpShow help information
--versionShow the version
-access-notes-path <path>Specify YAML file to override attributes on Swift declarations in this module
-assert-config <configuration>Specify the assert_configuration replacement
-async-mainResolve main function as if it were called from an asynchronous context
-clang-target <target>Separately set the target we should use for internal Clang instance
-color-diagnosticsPrint diagnostics in color
-continue-building-after-errorsContinue building, even after errors are encountered
-coverage-prefix-map <prefix>Remap source paths in coverage info
-debug-info-format <type>Specify the debug info format type
-debug-info-store-invocationEmit the compiler invocation in the debug info
-debug-prefix-map <prefix=replacement>Remap source paths in debug info
-diagnostic-style <style>The formatting style used when printing diagnostics
-disable-actor-data-race-checksDisable runtime checks for actor data races
-disable-autolinking-runtime-compatibility-concurrencyDo not use autolinking for the concurrency runtime compatibility library
-disable-autolinking-runtime-compatibility-dynamic-replacementsDo not use autolinking for the dynamic replacement runtime compatibility library
-disable-autolinking-runtime-compatibilityDo not use autolinking for runtime compatibility libraries
-disable-clang-targetDisable a separately specified target triple for Clang instance to use
-disable-incremental-importsDisable cross-module incremental build metadata and driver scheduling for Swift modules
-disable-only-one-dependency-fileDisables incremental build optimization that only produces one dependencies file
-disallow-use-new-driverDisable using new swift-driver
-D <flag>Marks a conditional compilation flag as true
-embed-tbd-for-module <module>Embed symbols from the module in the emitted tbd file
-enable-actor-data-race-checksEmit runtime checks for actor data races
-enable-bare-slash-regexEnable the use of forward slash regular-expression literal syntax
-enable-experimental-additive-arithmetic-derivationEnable experimental 'AdditiveArithmetic' derived conformances
-enable-experimental-concise-pound-fileEnable experimental concise '#file' identifier
-enable-experimental-cxx-interopAllow importing C++ modules into Swift (experimental feature)
-enable-experimental-forward-mode-differentiationEnable experimental forward mode differentiation
-enable-incremental-importsEnable cross-module incremental build metadata and driver scheduling for Swift modules
-enable-library-evolutionBuild the module to allow binary-compatible library evolution
-enable-only-one-dependency-fileEnables incremental build optimization that only produces one dependencies file
-enforce-exclusivity <enforcement>Enforce law of exclusivity
-experimental-cxx-stdlib <stdlib>C++ standard library to use; forwarded to Clang's -std lib flag
-file-compilation-dir <path>The compilation directory to embed in the debug info. Coverage mapping is not supported yet
-file-prefix-map <prefix>Remap source paths in debug, coverage, and index info
-framework <framework>Specifies a framework which should be linked against
-Fsystem <directory>Add directory to system framework search path
-F <directory>Add directory to framework search path
-gdwarf-typesEmit full DWARF type info
-gline-tables-onlyEmit minimal debug info for backtraces only
-gnoneDon't emit debug info
-gEmit debug info. This is the preferred setting for debugging with LLDB
-index-ignore-clang-modulesAvoid indexing clang modules (pcms)
-index-store-path <path>Store indexing data to path
-index-unit-output-path <path>Use the specified path as the output path in the produced index data
-I <directory>Add directory to the import search path
-j <value>Number of commands to execute in parallel
-libc <runtime>The libc runtime library to use
-locale <code>Choose a language for diagnostic messages
-localization-path <path>Path to localized diagnostic messages directory
-L <directory>Add directory to library link search path
-l <path>Specifies a library which should be linked against
-module-abi-name <name>ABI name to use for the contents of this module
-module-alias <alias>If a source file imports or references module <alias_name>, the <underlying_name> is used for the contents of the file
-module-cache-path <path>Specifies the Clang module cache path
-module-link-name <name>Library to link against when using this module
-module-name <name>Name of the module to build
-no-color-diagnosticsDo not print diagnostics in color
-no-warnings-as-errorsDon't treat warnings as error
-nostdimportDon't search the standard library import path for modules
-num-threads <value>Enable multi-threading and specify number of threads
-OnoneCompile without any optimization
-OsizeCompile with optimizations and target small code size
-OuncheckedCompile with optimizations and remove runtime safety checks
-OCompile with optimizations
-prefix-serialized-debugging-optionsApply debug prefix mappings to serialized debug info in Swiftmodule files
-pretty-printPretty-print the output JSON
-print-educational-notesInclude educational notes in printed diagnostic output, if available
-print-target-infoPrint target information for the given target <triple>, such as x86_64-apple-macos10.9
-Rcross-importEmit a remark if a cross-import of a module is triggered
-remove-runtime-assertsRemove runtime safety checks
-requirement-machine-abstract-signatures <value>Control usage of experimental generic signature minimization
-requirement-machine-inferred-signatures <value>Control usage of experimental generic signature minimization
-requirement-machine-protocol-signatures <value>Control usage of experimental protocol requirement signature minimization
-Rmodule-loadingEmit a remark and file path of each loaded module
-Rpass-missed <regex>Report missed transformations by optimization passes whose name matches the given POSIX regular expression
-Rpass <regex>Report performed transformations by optimization passes whose name matches the given POSIX regular expression
-runtime-compatibility-version <version>Link compatibility library for Swift runtime version, or 'none'
-save-optimization-record-passes <regex>Only include passes which match a specified regular expression in the generated optimization record (by default, include all passes)
-save-optimization-record-path <filename>Specify the file name of any generated optimization record
-save-optimization-record <format>Generate an optimization record file in a specific format
-save-optimization-recordGenerate a YAML optimization record file
-sdk <sdk>Compile against a specific SDK
-serialize-diagnostics-path <path>Emit a serialized diagnostics file
-static-executableStatically link the executable
-static-stdlibStatically link the Swift standard library
-strict-concurrency <concurrency>Specify the how strict concurrency checking will be
-suppress-warningsSuppress all warnings
-swift-isa-ptrauth-mode <mode>Mode for staging isa/super signing
-swift-ptrauth-mode <mode>Mode for staging pointer authentication
-swift-version <version>Interpret input according to a specific Swift language version number
-target-cpu <cpu>Generate code for a particular CPU variant
-target-min-inlining-version <version>Require inlinable code with no '@available' attribute to back-deploy to this version of the '-target' OS
-target-variant <variant>Generate 'zippered' code for macCatalyst that can run on the specified variant target triple in addition to the main -target triple
-target <triple>Generate code for the given target <triple>, such as x86_64-apple-macos10.9
-use-ld <linker>Specifies the linker to be used
-user-module-version <module>Module version specified from Swift module authors
-vfsoverlay <directory>Add directory to VFS overlay file
-vShow commands to run and use verbose output
-warn-concurrencyWarn about code that is unsafe according to the Swift Concurrency model and will become ill-formed in a future language version
-warn-implicit-overridesWarn about implicit overrides of protocol members
-warn-swift3-objc-inference-completeWarn about deprecated @objc inference in Swift 3 for every declaration that will no longer be inferred as @objc in Swift 4
-warn-swift3-objc-inference-minimalWarn about deprecated @objc inference in Swift 3 based on direct uses of the Objective-C entrypoint
-warnings-as-errorsTreat warnings as errors
-working-directory <directory>Resolve file paths relative to the specified directory
-Xcc <arg>Pass <arg> to the C/C++/Objective-C compiler
-Xlinker <arg>Specifies an option which should be passed to the linker