Open
Description
Is it reproducible with SwiftPM command-line tools: swift build
, swift test
, swift package
etc?
- Confirmed reproduction steps with SwiftPM CLI. The description text must include reproduction steps with either of command-line SwiftPM commands,
swift build
,swift test
,swift package
etc.
Description
- Create a package containing a build tool plugin.
- Return a
buildCommand
from theBuildToolPlugin.createBuildCommands(context:target:)
implementation. - Provide a non-empty list of
inputFiles
with thebuildCommand
. - Build the package in Xcode 16.2 or earlier.
- In Xcode build log observe
PhaseScriptExecution
entry, which exports bunch of environment variables to the generated shell script, which also exposed to the invocation of executable passed to thebuildCommand
.
Depending on the passedinputFiles
/outputFiles
arguments of thebuildCommand
, that might includeSCRIPT_INPUT_FILE_COUNT
,SCRIPT_INPUT_FILE_#
,SCRIPT_OUTPUT_FILE_COUNT
andSCRIPT_OUTPUT_FILE_#
variables, so build command executable can also read those environment variables. - If built in Xcode 16.4, a
CustomTask
entry could be found in build log, which doesn't generate a shell script and doesn't expose those environment variables. - The same behavior is observed if built with SwiftPM CLI by running
swift build
orswift build --build-system=native
. - If built with
swift build --build-system=xcode
, build tool plugin seems to be not invoked at all.
Expected behavior
Xcode 16.4 and SwiftPM CLI allow to preserve behavior of Xcode 16.2 and earlier, exposing environment variables to build tool plugin commands
Actual behavior
No response
Steps to reproduce
- Clone https://github.com/evnik/PluginTest example project
- Run
swift build
in the project directory - Observe
Error: SCRIPT_INPUT_FILE_COUNT variable not set
- Run
swift build --build-system=xcode
in the project directory - Observe
Build succeeded
- Open and built the project in Xcode 16.2 or earlier.
- Observe build tool plugin is successfully invoked and produces the next SwiftLint error:
<RedactedPath>/PluginTest/Sources/PluginTest/PluginTest.swift:2:9: error: Identifier Name Violation: Variable name 'i' should be between 3 and 40 characters long (identifier_name)
Swift Package Manager version/commit hash
6.1.0
Swift & OS version (output of swift --version ; uname -a
)
swift-driver version: 1.120.5 Apple Swift version 6.1.2 (swiftlang-6.1.2.1.2 clang-1700.0.13.5)
Target: arm64-apple-macosx15.0
Darwin m-tqvvvn2y4k 24.4.0 Darwin Kernel Version 24.4.0: Wed Mar 19 21:17:25 PDT 2025; root:xnu-11417.101.15~1/RELEASE_ARM64_T6020 arm64