[Pitch] Product-Builder plugin capability for SwiftPM

Hello Evan, thanks for your comments!

Just to clarify the scope: this proposal focuses on artifact construction. It defines how SwiftPM can produce a complete, potentially installable artifact, but not how or when that artifact is installed.

There was an earlier discussion around this distinction. Jon Shier made the IMO valid point that actual installation can already be handled by platform package managers such as Homebrew. Daniel Dunbar and Anders Bertelrud also discussed treating the construction of an installable artifact as a separate problem from its eventual installation or deployment. This proposal is concerned with that first part.

For questions such as rpath, install_name, embedded metadata, and similar platform-specific settings: yes, those belong to the Product Builder’s description of the final artifact.

The model I’m proposing keeps a SwiftPM-owned aggregation step. SwiftPM compiles the target closure and produces a private static archive containing the compiled code. It then gives the Product Builder that archive, the resources, the destination information, and the relevant structured build and linking context. The Product Builder owns the product-specific final link:

compiled targets → aggregate archive → Product Builder → final artifact

That distinction matters for rpath and install_name: neither is relevant on the intermediate static archive. They become meaningful on the final executable or dynamic library, so the Product Builder would normally set them as part of its final link.

If the model ultimately gives the Product Builder an already-linked product, I would use an approach similar to the one proposed for code signing. The linked file provided by SwiftPM would remain an immutable input. If the builder needed different rpath or install_namevalues, it could copy the file and modify the copy using a tool such as install_name_tool. The modified or signed result would be treated as a separate artifact.

This preserves input immutability and gives swift build a consistent incremental-build state across executions. If changing the artifact requires a true relink rather than an in-place metadata adjustment, the builder should receive structured link inputs and perform that final link itself, instead of attempting to reconstruct an opaque linker invocation.

The proposal does not currently define installation prefixes or a general policy for build-time versus installed rpath values. I see those as part of a broader installation design rather than this artifact-construction capability.

I hope this clarifies the intended scope and where that final linkage boundary sits!

1 Like