<!--
{
  "availability" : [
    "Swift: 6.2.0 -",
    "Xcode: 26.0.0 -",
    "iOS: -",
    "iPadOS: -",
    "macCatalyst: -",
    "macOS: -",
    "swift: 6.0.0 -",
    "tvOS: -",
    "visionOS: -",
    "watchOS: -"
  ],
  "documentType" : "symbol",
  "framework" : "Testing",
  "identifier" : "/documentation/Testing/Attachment/init(_:named:sourceLocation:)",
  "metadataVersion" : "0.1.0",
  "role" : "Initializer",
  "symbol" : {
    "kind" : "Initializer",
    "modules" : [
      "Swift Testing",
      "Testing"
    ],
    "preciseIdentifier" : "s:7Testing10AttachmentVAARi_zrlE_5named14sourceLocationACyxGx_SSSgAA06SourceE0Vtcfc"
  },
  "title" : "init(_:named:sourceLocation:)"
}
-->

# init(_:named:sourceLocation:)

Initialize an instance of this type that encloses the given attachable
value.

```
init(_ attachableValue: consuming AttachableValue, named preferredName: String? = nil, sourceLocation: SourceLocation = #_sourceLocation)
```

## Parameters

`attachableValue`

The value that will be attached to the output of the
test run.

`preferredName`

The preferred name of the attachment to use when saving
it. If `nil`, the testing library attempts to generate a reasonable
filename for the attached value.

`sourceLocation`

The source location of the call to this initializer.
This value is used when recording issues associated with the
attachment.

---

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)