---
title: "writeBookmarkData(_:to:)"
framework: foundation
role: symbol
role_heading: Type Method
path: "foundation/url/writebookmarkdata(_:to:)"
---

# writeBookmarkData(_:to:)

Creates an alias file on disk at a specified location with specified bookmark data.

## Declaration

```swift
static func writeBookmarkData(_ data: Data, to url: URL) throws
```

## Discussion

Discussion The data must have been created with the suitableForBookmarkFile option. The url must either refer to an existing file (which will be overwritten), or to location in an existing directory.

## See Also

### Creating bookmarks

- [bookmarkData(options:includingResourceValuesForKeys:relativeTo:)](foundation/url/bookmarkdata(options:includingresourcevaluesforkeys:relativeto:).md)
- [bookmarkData(withContentsOf:)](foundation/url/bookmarkdata(withcontentsof:).md)
- [resourceValues(forKeys:fromBookmarkData:)](foundation/url/resourcevalues(forkeys:frombookmarkdata:).md)
- [URL.BookmarkCreationOptions](foundation/url/bookmarkcreationoptions.md)
- [NSURL.BookmarkCreationOptions](foundation/nsurl/bookmarkcreationoptions.md)
