Skip to content

[6.4] Emit warning for unhandled files in SwiftBuild; Avoid unnecessary network requests#10143

Open
bripeticca wants to merge 2 commits into
swiftlang:release/6.4.xfrom
bripeticca:release/6.4.x
Open

[6.4] Emit warning for unhandled files in SwiftBuild; Avoid unnecessary network requests#10143
bripeticca wants to merge 2 commits into
swiftlang:release/6.4.xfrom
bripeticca:release/6.4.x

Conversation

@bripeticca
Copy link
Copy Markdown
Contributor

Cherry-picks of #10132, #10140

bripeticca and others added 2 commits May 29, 2026 12:48
…when using `--force-resolved-versions` (swiftlang#10140)

This change modifies the behaviour of attempting to resolve using the
`Package.resolved` file as a lock file, wherein the user passes the
`--force-resolved-versions` flag with the possibility of a fully
populated `.build/checkouts` cache to avoid making any network requests.

### Motivation:

For workspaces that have just been fully resolved with an updated
checkouts cache and workspace state, it is unnecessary to make network
requests; if a project has migrated environments (such as pushing a
project to a container for CI) where network connection is either
limited (perhaps there are private or enterprise repositories used) or
disallowed, SwiftPM should first try to operate off of the local state
entirely by verifying the existence of the package checkouts, and only
if the state is stale should it attempt to make a network request.

### Modifications:

In `tryResolveBasedOnResolvedVersionsFile`, first check the managed
dependencies state against each pinned package version present in the
`Package.resolved`. If package dependencies exist that don't align with
the current workspace state, then it will be added to a list of packages
to be fetched.

### Result:

Unnecessary network requests will no longer be made, allowing for full
local resolution if the .build directory is in a good state and a
Package.resolved exists.
Original PR: swiftlang#9532 by @pepicrft 

Taken over so as to get through CI + address PR comments.

Original PR comment:

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
swiftlang#8786) to
remove that condition since the fix resolves it.

Fixes swiftlang#8786

---------

Co-authored-by: Pedro Piñera <pedro@pepicrft.me>
Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
@bripeticca
Copy link
Copy Markdown
Contributor Author

@swift-ci test

@bripeticca bripeticca enabled auto-merge (squash) May 29, 2026 17:02
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.

1 participant