swift_package_workspace

Native Swift Package Manager workspace seed.

Description#

swift_package_workspace reads Package.swift through Swift Package Manager and lowers first-party libraries, executables, macros, binary targets, and tests into the existing Apple target kinds. The package manifest remains authoritative for products, target dependencies, source layout, compiler settings, resources, and platform constraints.

Executable products are linked into Apple application bundles, so their compiled executable is a declared build output alongside the bundle metadata.

Once discovers a workspace automatically from Package.swift. A repository without once.toml can therefore query and build its first-party package targets directly. Discovery skips generated package-manager state such as .build and .swiftpm.

For source-control dependencies, the resolver uses Package.resolved or asks Swift Package Manager to create it when it is absent. It materializes the pinned sources and lowers their package targets into the same Apple target kinds. Once compiles those targets directly with the selected Swift compiler. Swift Package Manager supplies manifest and lockfile metadata, but does not build the dependency products. Registry dependencies are not supported by native package lowering yet.

Attributes#

AttributeTypeRequiredDefaultDescription
package_pathstringno.Package-relative directory containing Package.swift
resolver_inputslist<string>nosrcsPackage-relative source globs available while deriving the graph
platformstringnomacosApple platform used when lowering package targets
minimum_osstringno13.0Minimum operating system version for lowered targets
sdk_variantstringnosimulatorSimulator or device software development kit selection; ignored for macOS
swiftstringnoswiftSwift Package Manager executable; the default is paired with the selected Swift compiler
xcode_developer_dirstringnoSpecific Xcode developer directory
package_namestringnogeneratedDisplay name read from Package.swift while resolving. This value is generated by the resolver and must not be set in a manifest.

Providers and capabilities#

The target emits swift_package_workspace and exposes the build capability. The resolver emits the first-party Apple targets that implement the actual build products.

Direct use#

Inspect the automatically derived graph without writing a manifest:

bash
once query workspace
once query targets

To configure the resolver explicitly, author a seed equivalent to:

toml
[[target]]
name = "swift_package"
kind = "swift_package_workspace"
srcs = ["Package.swift"]
[target.attrs]
resolver_inputs = [
"Package.swift",
"Package.resolved",
"Sources/**/*",
"Tests/**/*",
"Plugins/**/*",
"Macros/**/*",
"**/Package.swift",
"**/Package.resolved",
]

Use swift_package_dependencies when an explicit Apple target needs selected static products from a locked package graph rather than native first-party package lowering.

Sources#