Skip to content

SPM Build Options

SPM build options control how an SPM project is compiled and linked. They are shared across the build, run, test, and archive commands.

OptionDescription
-p, --path <path>Path to the SPM project. Defaults to current directory
--build-dir <path>Path to the build directory. Defaults to .build
-o, --output <path>Path to the output directory. Defaults to Product
OptionDescription
-c, --configuration <type>Build configuration: debug (default) or release
--os-version <version>Minimum OS version or Android API level
--static-swift-stdlibLink with the static Swift standard library
--debug-info-format <format>Debug info format: dwarf (default), codeview, or none
--sdk <path>Path to the target SDK sysroot
--pkg-config-path <path>Additional directory to search for .pc files. Repeatable
--build-testsBuild test targets
OptionDescription
--target <name>SPM target to build. Repeatable. Defaults to all targets
--product <name>SPM product to build. Repeatable. Defaults to all products

Flags can be passed globally (applied to all platforms) or scoped to a specific platform using the :<platform> suffix.

Platforms: macos, ios, ios-simulator, android-arm64-v8a, android-armeabi-v7a, android-x86_64, android-x86

OptionDescription
-Xcc <flag>Pass flag to all C compiler invocations
-Xcc:<platform> <flag>Pass flag to C compiler invocations for the given platform
-Xswiftc <flag>Pass flag to all Swift compiler invocations
-Xswiftc:<platform> <flag>Pass flag to Swift compiler invocations for the given platform
-Xcxx <flag>Pass flag to all C++ compiler invocations
-Xcxx:<platform> <flag>Pass flag to C++ compiler invocations for the given platform
-Xlinker <flag>Pass flag to all linker invocations
-Xlinker:<platform> <flag>Pass flag to linker invocations for the given platform
OptionDescription
-L, --link-library-path <path>Add a library search path. Repeatable
--link-library-path:<platform> <path>Add a library search path for the given platform. Repeatable
-l, --link-library <name>Link against a library. Repeatable
--link-library:<platform> <name>Link against a library for the given platform. Repeatable
OptionDescription
--java-sources <path>Path to additional Java sources to compile into JAR archives