<!--
{
  "availability" : [
    "SwiftPM: 6.1.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "PackageDescription",
  "identifier" : "/documentation/PackageDescription/TargetDependencyCondition/when(platforms:traits:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "PackageDescription"
    ],
    "preciseIdentifier" : "s:18PackageDescription25TargetDependencyConditionV4when9platforms6traitsACSgSayAA8PlatformVG_ShySSGtFZ"
  },
  "title" : "when(platforms:traits:)"
}
-->

# when(platforms:traits:)

Creates a target dependency condition.

```
static func when(platforms: [Platform], traits: Set<String>) -> TargetDependencyCondition?
```

## Parameters

`platforms`

The applicable platforms for this target dependency condition.

`traits`

The applicable traits for this target dependency condition.

---

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)