Emit warning for unhandled files in SwiftBuild #9532
+43
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
When building with the native build system, SwiftPM emits a warning if there are files in a target's source directory that aren't being handled - they're not Swift sources, not declared as resources, and not explicitly excluded. This is helpful for catching forgotten files or misconfigurations. However, when using SwiftBuild, this warning was silently skipped, which could lead to confusion when switching between build systems.
I traced the issue to
PIFBuilder.swift, which generates the PIF representation for SwiftBuild but was missing the diagnostic check thatBuildOperation.swiftperforms for the native build system. The fix adds adiagnoseUnhandledFilesmethod toPIFBuilderthat mirrors the native implementation - it runs after plugin invocation, checks for files inmodule.underlying.othersthat weren't handled by any build tool plugins, and emits the same warning with proper metadata.I also updated the existing test in
PluginTests.swiftthat was marked as a known issue for SwiftBuild (referencing this exact issue #8786) to remove that condition since the fix resolves it.Fixes #8786