Hey everyone,
Recently I was trying to add a debug-only dependency to a package target, which is something that comes up in practically every project, something I'd expect to be straightforward, only to discover that while target dependencies do support conditions, those conditions can only be platform- or trait-based, not configuration-based. That sent me digging into SE-0273 (Package Manager Conditional Target Dependencies), where I noticed something interesting: the proposal was accepted and implemented back in 2020, but configuration conditionals never made it in, as reflected in its current status: Partially implemented (Swift 5.3 supports platform conditionals, but not configuration conditionals). From what I can tell, the original blocker no longer exists (more on that below), and 2026 seems like a great time to finally close the gap.
Why it was blocked
PR #2428 actually implemented configuration-based conditionals at the build plan level, but got stuck on one specific problem: Xcode projects and generate-xcodeproj along with it, had no way to conditionalize target dependencies by configuration. So it was decided to shelve the feature for better times.
Why that blocker is gone
Well, better times are here. generate-xcodeproj was removed 2 years later in August 2022 alongside Swift 5.7 (PR #5748) since Xcode now integrates SPM packages natively, so the original reason for not shipping configuration conditionals no longer exists.
Why it matters
The original proposal actually spelled this out explicitly:
"packages may want to link against libraries only in certain configurations, for example when importing debug libraries, which do not make sense to build and link in release builds, or when importing instrumentation logic, which only make sense in release builds"
So the use case was always there: hot-reload tools, inspection libraries, debug helpers: none of these have any business being built and linked into release binaries, yet there's no clean SPM-native way to express this.
Next steps
The groundwork from PR #2428 is already there, so hopefully it's mostly a matter of picking it back up and adapting it to the current codebase. I'd love to make this happen and happy to contribute if needed, but before diving in: are there any known blockers or complications I might have missed?