<!--
{
  "availability" : [
    "macOS: 10.0.0 - 10.10.0"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/FileWrapper/addSymbolicLink(withDestination:preferredFilename:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "c:objc(cs)NSFileWrapper(im)addSymbolicLinkWithDestination:preferredFilename:"
  },
  "title" : "addSymbolicLink(withDestination:preferredFilename:)"
}
-->

# addSymbolicLink(withDestination:preferredFilename:)

Creates a symbolic-link file wrapper pointing to a given file-system node and adds it to the receiver, which must be a directory file wrapper.

```
func addSymbolicLink(withDestination path: String, preferredFilename filename: String) -> String
```

## Parameters

`path`

Pathname the new symbolic-link file wrapper is to reference.

`filename`

Preferred filename for the new symbolic-link file wrapper.

## Return Value

Dictionary key used to store the new file wrapper in the directory’s list of file wrappers. See [Accessing File Wrapper Identities](https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/FileWrappers/FileWrappers.html#//apple_ref/doc/uid/TP40010672-CH13-SW1) in [File System Programming Guide](https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/FileSystemProgrammingGuide/Introduction/Introduction.html#//apple_ref/doc/uid/TP40010672) for more information.

## Discussion

Beginning with OS X v10.6, the preferred method of referring to files is with a `file://` URL. Instead of using this method, you can instantiate `NSFileWrapper` with one of the initializers, set its [`preferredFilename`](/documentation/Foundation/FileWrapper/preferredFilename) property if necessary, and pass the result to [`addFileWrapper(_:)`](/documentation/Foundation/FileWrapper/addFileWrapper(_:)).

This method raises `NSInternalInconsistencyException` if the receiver is not a directory file wrapper.

This method raises `NSInvalidArgumentException` if you pass `nil` or an empty value for `preferredFilename`.

---

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)