Skip to content

Conversation

@pepicrft
Copy link

@pepicrft pepicrft commented Dec 20, 2025

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 that BuildOperation.swift performs for the native build system. The fix adds a diagnoseUnhandledFiles method to PIFBuilder that mirrors the native implementation - it runs after plugin invocation, checks for files in module.underlying.others that weren't handled by any build tool plugins, and emits the same warning with proper metadata.

I also updated the existing test in PluginTests.swift that was marked as a known issue for SwiftBuild (referencing this exact issue #8786) to remove that condition since the fix resolves it.

Fixes #8786

The native build system emits a warning when source directories contain
files that are not handled by the build (not Swift sources, not declared
as resources, and not excluded). SwiftBuild was missing this diagnostic,
creating an inconsistency between the two build systems.

This adds the diagnoseUnhandledFiles check to PIFBuilder.swift, mirroring
the implementation in BuildOperation.swift for the native build system.

Fixes swiftlang#8786

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Swiftbuild build system doesn't emit warning message for unused files

1 participant