<!--
{
  "availability" : [
    "iOS: 18.2.0 -",
    "iPadOS: 18.2.0 -",
    "macCatalyst: 18.2.0 -",
    "macOS: 15.2.0 -",
    "tvOS: 18.2.0 -",
    "visionOS: 2.2.0 -",
    "watchOS: 11.2.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "CoreTransferable",
  "identifier" : "/documentation/CoreTransferable/Transferable/export(to:contentType:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "Core Transferable",
      "CoreTransferable"
    ],
    "preciseIdentifier" : "s:16CoreTransferable0B0PAAE6export2to11contentType10Foundation3URLVAI_07UniformF11Identifiers6UTTypeVSgtYaKF"
  },
  "title" : "export(to:contentType:)"
}
-->

# export(to:contentType:)

Using the type’s `Transferable` conformance implementation,
exports a value by writing it to a provided destination directory.

```
func export(to destinationDirectory: URL, contentType: UTType?) async throws -> URL
```

## Parameters

`destinationDirectory`

A directory to write the file to.

`contentType`

A content type of the requested file.
If `nil`, the first transfer representation is be used.

## Return Value

A URL of the created file. The file is owned by the application,
and it is responsible for removing it when the file is not needed anymore.

## Discussion

If the [`Transferable`](/documentation/CoreTransferable/Transferable) is not backed by a file,
this will write the data to specified destination.
This function uses the first representation provided for a given type
in `static var transferRepresentation` requirement of the `Transferable` protocol
or in the `body` of a custom `TransferRepresentation`.

The default implementation of this function is available to all types that conform
to `Transferable` protocol.

---

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)