<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "XCTest",
  "identifier" : "/documentation/XCTest/XCTAttachment/uniformTypeIdentifier",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Property",
  "symbol" : {
    "kind" : "Instance Property",
    "modules" : [
      "XCTest"
    ],
    "preciseIdentifier" : "c:objc(cs)XCTAttachment(py)uniformTypeIdentifier"
  },
  "title" : "uniformTypeIdentifier"
}
-->

# uniformTypeIdentifier

The Uniform Type Identifier (UTI) of the data represented by the attachment.

```
var uniformTypeIdentifier: String { get }
```

## Discussion

Uniform Type Identifiers (UTIs) are Apple-defined identifiers that uniquely identify a particular type of data, such as a JPEG image or text document. Every [`XCTAttachment`](/documentation/XCTest/XCTAttachment) instance stores a UTI string that indicates the type of data represented by the attachment.

When you create an attachment with an [`XCTAttachment`](/documentation/XCTest/XCTAttachment) convenience initializer such as [`init(contentsOfFileAtURL:)`](/documentation/XCTest/XCTAttachment/init(contentsOfFileAtURL:)) or [`init(plistObject:)`](/documentation/XCTest/XCTAttachment/init(plistObject:)), XCTest determines an appropriate UTI to use for the provided data. See each convenience initializer for more information about the UTIs it uses.

Where possible, you should use the [`XCTAttachment`](/documentation/XCTest/XCTAttachment) convenience initializers to create attachments for known data types. If you need to create an attachment with a manually specified UTI (such as for a custom data format used by your app), use one of the following initializers instead:

- [`init(archivableObject:uniformTypeIdentifier:)`](/documentation/XCTest/XCTAttachment/init(archivableObject:uniformTypeIdentifier:)) for custom data stored in an object that conforms to <doc://com.apple.documentation/documentation/Foundation/NSSecureCoding>
- [`init(contentsOfFileAtURL:uniformTypeIdentifier:)`](/documentation/XCTest/XCTAttachment/init(contentsOfFileAtURL:uniformTypeIdentifier:)) for reading the contents of a file with a known custom UTI
- [`init(data:uniformTypeIdentifier:)`](/documentation/XCTest/XCTAttachment/init(data:uniformTypeIdentifier:)) for data stored in memory with a known custom UTI
- [`init(uniformTypeIdentifier:name:payload:userInfo:)`](/documentation/XCTest/XCTAttachment/init(uniformTypeIdentifier:name:payload:userInfo:)) for a data payload with a custom UTI, name, and user info dictionary

For more information about UTIs, see [Uniform Type Identifiers Overview](https://developer.apple.com/library/archive/documentation/FileManagement/Conceptual/understanding_utis/understand_utis_intro/understand_utis_intro.html#//apple_ref/doc/uid/TP40001319). For a list of system-declared UTIs, see [Uniform Type Identifiers Reference](https://developer.apple.com/library/archive/documentation/Miscellaneous/Reference/UTIRef/Introduction/Introduction.html#//apple_ref/doc/uid/TP40009257).

---

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)