Skip to content

Traits apply to packages instead of products #8350

Open
@davedelong

Description

@davedelong

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

As reported here: https://forums.swift.org/t/cross-import-overlay-status/74090/9

It is a design flaw that traits apply to packages instead of single products. A package can provide many products, and each product may have their own unique set of traits that it wants to expose, and a client may not want to apply all traits to every product.

For example, a package that exposes both a "logic" product and a "UI" product that provides SwiftUI views around the types in the logic product could easily have traits that only apply to one or the other. Perhaps a Debug trait might apply to both, but an ProvideUIKitBindings might only apply to the UI product.

Traits should be defined on the product, not the package.

Expected behavior

No response

Actual behavior

No response

Steps to reproduce

No response

Swift Package Manager version/commit hash

Swift Package Manager - Swift 6.0.3

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

swift-driver version: 1.115.1 Apple Swift version 6.0.3 (swiftlang-6.0.3.1.9 clang-1600.0.30.1)

Darwin Localhost 24.3.0 Darwin Kernel Version 24.3.0: Thu Jan 2 20:24:23 PST 2025; root:xnu-11215.81.4~3/RELEASE_ARM64_T6020 arm64

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions