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

# byName(name:)

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

```
static func byName(name: String) -> Target.Dependency
```

## Parameters

`name`

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

## Return Value

A `Target.Dependency` instance.
The 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)