---
title: "createSymbolicLink(named:in:attributes:linkContents:context:replyHandler:)"
framework: fskit
role: symbol
role_heading: Instance Method
path: "fskit/fsvolume/handler/createsymboliclink(named:in:attributes:linkcontents:context:replyhandler:)"
---

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

Creates a new symbolic link.

## Declaration

```swift
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)
```

```swift
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 doc://FSKit/documentation/FSKit/FSCreateSymlinkResult containing the newly-created doc://FSKit/documentation/FSKit/FSItem, its doc://FSKit/documentation/FSKit/FSFileName, its doc://FSKit/documentation/FSKit/FSItem/Attributes, the updated doc://FSKit/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 doc://FSKit/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

Discussion If an item named name already exists in the directory indicated by directory, complete the request with an error with a domain of NSPOSIXErrorDomain and a code of EEXIST.

## See Also

### Working with links

- [createLink(to:named:in:context:replyHandler:)](fskit/fsvolume/handler/createlink(to:named:in:context:replyhandler:).md)
- [FSCreateLinkResult](fskit/fscreatelinkresult.md)
- [FSCreateSymlinkResult](fskit/fscreatesymlinkresult.md)
- [readSymbolicLink(_:context:replyHandler:)](fskit/fsvolume/handler/readsymboliclink(_:context:replyhandler:).md)
- [FSReadSymlinkResult](fskit/fsreadsymlinkresult.md)
