From 3b8655c54a45682f41d7ef078402b3cc9c74a9bb Mon Sep 17 00:00:00 2001 From: Dave Verwer Date: Mon, 4 Aug 2025 10:25:15 +0100 Subject: [PATCH 1/2] Added documentation for `SPI_PROCESSING`. --- Sources/SPIManifest/Documentation.docc/CommonUseCases.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/Sources/SPIManifest/Documentation.docc/CommonUseCases.md b/Sources/SPIManifest/Documentation.docc/CommonUseCases.md index 9bd323f..32d77f8 100644 --- a/Sources/SPIManifest/Documentation.docc/CommonUseCases.md +++ b/Sources/SPIManifest/Documentation.docc/CommonUseCases.md @@ -83,6 +83,14 @@ builder: There is also a `target:` key in order to configure a specific target instead of a scheme, where applicable. +### Implementing custom package logic with SPI_PROCESSING + +When the Swift Package Index processes your package, you’ll find the `SPI_PROCESSING` environment variable set during two key processes: + +- **Analysis**: Swift Package Index extracts package metadata by running `swift package dump-package`. Packages _must_ pass analysis to be included in the index. +- **Compatibility builds**: Swift Package Index runs either `swift build` or `xcodebuild` to determine Swift version and platform compatibility. + +See the [swift-java](https://swiftpackageindex.com/swiftlang/swift-java) package for an example of a package using this feature, where the authors [bypass a JDK requirement](https://github.com/swiftlang/swift-java/blob/a3791cf7c94146a34f96fd9ad53efef9d58c2a1b/Package.swift#L35) during analysis. Without this exception, the Swift Package Index analysis machines couldn’t successfully run `swift package dump-package`. ## Images for Linux From 4201825c0c49ac9d807549abed678d64d1d9de7f Mon Sep 17 00:00:00 2001 From: "Sven A. Schmidt" Date: Mon, 4 Aug 2025 14:11:32 +0200 Subject: [PATCH 2/2] Document SPI_BUILD env variable --- Sources/SPIManifest/Documentation.docc/CommonUseCases.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Sources/SPIManifest/Documentation.docc/CommonUseCases.md b/Sources/SPIManifest/Documentation.docc/CommonUseCases.md index 32d77f8..6e654d5 100644 --- a/Sources/SPIManifest/Documentation.docc/CommonUseCases.md +++ b/Sources/SPIManifest/Documentation.docc/CommonUseCases.md @@ -85,13 +85,15 @@ There is also a `target:` key in order to configure a specific target instead of ### Implementing custom package logic with SPI_PROCESSING -When the Swift Package Index processes your package, you’ll find the `SPI_PROCESSING` environment variable set during two key processes: +When the Swift Package Index processes your package, you’ll find the `SPI_PROCESSING` environment variable set during all processessing, in particular the following: - **Analysis**: Swift Package Index extracts package metadata by running `swift package dump-package`. Packages _must_ pass analysis to be included in the index. - **Compatibility builds**: Swift Package Index runs either `swift build` or `xcodebuild` to determine Swift version and platform compatibility. See the [swift-java](https://swiftpackageindex.com/swiftlang/swift-java) package for an example of a package using this feature, where the authors [bypass a JDK requirement](https://github.com/swiftlang/swift-java/blob/a3791cf7c94146a34f96fd9ad53efef9d58c2a1b/Package.swift#L35) during analysis. Without this exception, the Swift Package Index analysis machines couldn’t successfully run `swift package dump-package`. +In addition, the variable `SPI_BUILD` is set exclusively during the compatibility build phase. This allows package authors to include specific package manifest configurations for builds in the context of the Swift Package Index. Again, the [swift-java](https://swiftpackageindex.com/swiftlang/swift-java) package is an example of a package making use of this capability. + ## Images for Linux Package authors can also use the `.spi.yml` file to configure custom docker base images for our Linux builds.