<!--
{
  "availability" : [
    "iOS: 8.0.0 -",
    "iPadOS: 8.0.0 -",
    "macCatalyst: 8.0.0 -",
    "macOS: 10.10.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -",
    "watchOS: 2.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "Foundation",
  "identifier" : "/documentation/Foundation/URL/writeBookmarkData(_:to:)",
  "metadataVersion" : "0.1.0",
  "role" : "Type Method",
  "symbol" : {
    "kind" : "Type Method",
    "modules" : [
      "Foundation"
    ],
    "preciseIdentifier" : "s:10Foundation3URLV17writeBookmarkData_2toyAA0E0V_ACtKFZ"
  },
  "title" : "writeBookmarkData(_:to:)"
}
-->

# writeBookmarkData(_:to:)

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

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

## Discussion

The `data` must have been created with the [`suitableForBookmarkFile`](/documentation/Foundation/NSURL/BookmarkCreationOptions/suitableForBookmarkFile) option. The `url` must either refer to an existing file (which will be overwritten), or to location in an existing directory.

---

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)