---
title: "init(contentsOfFile:uniformTypeIdentifier:)"
framework: xctest
role: symbol
role_heading: Initializer
path: "xctest/xctattachment/init(contentsoffile:uniformtypeidentifier:)"
---

# init(contentsOfFile:uniformTypeIdentifier:)

## Declaration

```swift
convenience init(contentsOfFile url: URL, uniformTypeIdentifier identifier: String)
```

## Discussion

Discussion Creates an attachment with an existing file on disk and type. note: Only works for files, not directories.
