<!--
{
  "availability" : [

  ],
  "documentType" : "symbol",
  "framework" : "XCTest",
  "identifier" : "/documentation/XCTest/XCTAttachment/init(screenshot:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "XCTest"
    ],
    "preciseIdentifier" : "c:objc(cs)XCTAttachment(cm)attachmentWithScreenshot:"
  },
  "title" : "init(screenshot:)"
}
-->

# init(screenshot:)

Creates an attachment containing a PNG representation of the provided screenshot.

```
convenience init(screenshot: XCUIScreenshot)
```

## Parameters

`screenshot`

The screenshot to wrap as an attachment.

## Discussion

Creates an attachment with a [`uniformTypeIdentifier`](/documentation/XCTest/XCTAttachment/uniformTypeIdentifier) of `"public.png"`. Equivalent to calling [`init(screenshot:quality:)`](/documentation/XCTest/XCTAttachment/init(screenshot:quality:)) with a `quality` value of [`XCTAttachment.ImageQuality.original`](/documentation/XCTest/XCTAttachment/ImageQuality/original).

---

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)