---
title: "init(uniformTypeIdentifier:name:payload:userInfo:)"
framework: xctest
role: symbol
role_heading: Initializer
path: "xctest/xctattachment/init(uniformtypeidentifier:name:payload:userinfo:)"
---

# init(uniformTypeIdentifier:name:payload:userInfo:)

Creates an attachment containing the provided data payload, optionally with a custom UTI, name, and user-provided metadata dictionary.

## Declaration

```swift
init(uniformTypeIdentifier identifier: String?, name: String?, payload: Data?, userInfo: [AnyHashable : Any]? = nil)
```

## Parameters

- `identifier`: An optional custom UTI to represent the data’s content type.
- `name`: An optional name for the attachment, to be used in Xcode’s test reports.
- `payload`: The data to wrap as an attachment.
- `userInfo`: An optional dictionary of user-provided metadata to associate with the attachment.

## Discussion

Discussion Creates an attachment with a uniformTypeIdentifier of "public.data" if the identifier parameter is nil.

## See Also

### Creating Attachments from Data

- [init(data:)](xctest/xctattachment/init(data:).md)
- [init(data:uniformTypeIdentifier:)](xctest/xctattachment/init(data:uniformtypeidentifier:).md)
