<!--
{
  "availability" : [
    "macOS: 27.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "FSKit",
  "identifier" : "/documentation/FSKit/FSVolume/Handler/createSymbolicLink(named:in:attributes:linkContents:context:replyHandler:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "FSKit"
    ],
    "preciseIdentifier" : "c:objc(pl)FSVolumeHandler(im)createSymbolicLinkNamed:inDirectory:attributes:linkContents:context:replyHandler:"
  },
  "title" : "createSymbolicLink(named:in:attributes:linkContents:context:replyHandler:)"
}
-->

# createSymbolicLink(named:in:attributes:linkContents:context:replyHandler:)

Creates a new symbolic link.

```
func createSymbolicLink(named name: FSFileName, in directory: FSItem, attributes newAttributes: FSItem.SetAttributesRequest, linkContents contents: FSFileName, context: FSContext, replyHandler reply: @escaping @Sendable (FSCreateSymlinkResult?, (any Error)?) -> Void)
```

```
func createSymbolicLink(named name: FSFileName, in directory: FSItem, attributes newAttributes: FSItem.SetAttributesRequest, linkContents contents: FSFileName, context: FSContext) async throws -> FSCreateSymlinkResult
```

## Parameters

`name`

The new item’s name.

`directory`

The directory in which to create the item.

`newAttributes`

Attributes to apply to the new item.

`contents`

The contents of the new symbolic link.

`context`

An object that enables context-aware file system decisions throughout the operation.

`reply`

A block or closure to indicate success or failure. If creation succeeds, pass an instance of [`FSCreateSymlinkResult`](/documentation/FSKit/FSCreateSymlinkResult) containing the newly-created [`FSItem`](/documentation/FSKit/FSItem), its [`FSFileName`](/documentation/FSKit/FSFileName), its [`FSItem.Attributes`](/documentation/FSKit/FSItem/Attributes), the updated [`FSItem.Attributes`](/documentation/FSKit/FSItem/Attributes) of the parent directory, and the volume’s updated free space, along with a `nil` error. If creation fails, pass the relevant error as the second parameter; FSKit ignores the [`FSCreateSymlinkResult`](/documentation/FSKit/FSCreateSymlinkResult) instance in this case. For an `async` Swift implementation, there’s no reply handler; simply return the result instance or throw an error.

## Discussion

If an item named `name` already exists in the directory indicated by `directory`, complete the request with an error with a domain of <doc://com.apple.documentation/documentation/Foundation/NSPOSIXErrorDomain> and a code of `EEXIST`.

---

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)