<!--
{
  "availability" : [
    "SwiftPM: 5.3.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "PackageDescription",
  "identifier" : "/documentation/PackageDescription/Target/Dependency/byName(name:condition:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "PackageDescription"
    ],
    "preciseIdentifier" : "s:18PackageDescription6TargetC10DependencyO6byName4name9conditionAESS_AA0cD9ConditionVSgtFZ"
  },
  "title" : "byName(name:condition:)"
}
-->

# byName(name:condition:)

Creates a dependency that resolves to either a target or a product with
the specified name.

```
static func byName(name: String, condition: TargetDependencyCondition? = nil) -> Target.Dependency
```

## Parameters

`name`

The name of the dependency, either a target or a product.

`condition`

A condition that limits the application of the target
dependency. For example, only apply a dependency for a specific
platform.

## Return Value

A `Target.Dependency` instance.

## Discussion

Swift Package Manager creates the by-name dependency after it has loaded the package
graph.

---

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)