Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Traits] Used package dependency omitted when traits guard some target dependencies #8398

Closed
1 task done
bripeticca opened this issue Mar 20, 2025 · 0 comments · Fixed by #8399
Closed
1 task done
Assignees
Labels

Comments

@bripeticca
Copy link
Contributor

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

The computation for trait-guarded dependencies did not consider differentiating between product target dependencies coming from the same package wherein one could be trait-guarded and the other could be enabled, causing it to preemptively omit the package dependency entirely if it encounters a trait guard.

Expected behavior

SwiftPM should ensure that it computes the target dependencies that are being trait-guarded, and assure that a dependency is only guarded if every instance of it appears to be trait-guarded. Otherwise, it should include this dependency if it's being used.

Actual behavior

SwiftPM preemptively omits a package dependency it believes to be trait-guarded when there are existing target dependencies that aren't guarded.

Steps to reproduce

Download the attached example project and run a swift build in the root directory; note that it errors out with:

[0/1] Planning build
Building for debugging...
[0/4] Write swift-version--58304C5D6DBC2206.txt
error: emit-module command failed with exit code 1 (use -v to see invocation)
[2/6] Emitting module root
<unknown>:0: error: missing required module 'bestlowest'
[3/6] Compiling root main.swift
<unknown>:0: error: missing required module 'bestlowest'

packtest.zip

Swift Package Manager version/commit hash

No response

Swift & OS version (output of swift --version ; uname -a)

No response

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant