<!--
{
  "availability" : [
    "SwiftPM: 6.1.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "PackageDescription",
  "identifier" : "/documentation/PackageDescription/Trait/name",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "PackageDescription"
    ],
    "preciseIdentifier" : "s:18PackageDescription5TraitV4nameSSvp"
  },
  "title" : "name"
}
-->

# name

The trait’s canonical name.

```
var name: String
```

## Discussion

Use the trait’s name to enable the trait or when referring to it from other modifiers in the manifest.
The trait’s name also defines the conditional block that the compiler supports when the trait is active.

The following rules are enforced on trait names:

- The first character must be a [Unicode XID start character](https://unicode.org/reports/tr31/#Figure_Code_Point_Categories_for_Identifier_Parsing)
  (most letters), a digit, or `_`.
- Subsequent characters must be a [Unicode XID continue character](https://unicode.org/reports/tr31/#Figure_Code_Point_Categories_for_Identifier_Parsing)
  (a digit, `_`, or most letters), `-`, or `+`.
- The names `default` and `defaults` (in any letter casing combination) aren’t allowed as trait names to avoid confusion with default traits.

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)