You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
// This source file is part of the Swift.org open source project
3
+
//
4
+
// Copyright (c) 2026 Apple Inc. and the Swift project authors
5
+
// Licensed under Apache License v2.0 with Runtime Library Exception
6
+
//
7
+
// See https://swift.org/LICENSE.txt for license information
8
+
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
9
+
//
10
+
11
+
#if canImport(CoreTransferable)
12
+
publicimport Testing
13
+
publicimport CoreTransferable
14
+
15
+
publicimport UniformTypeIdentifiers
16
+
17
+
@_spi(Experimental)
18
+
@available(_transferableAPI,*)
19
+
extensionAttachment{
20
+
/// Initialize an instance of this type that encloses the given transferable
21
+
/// value.
22
+
///
23
+
/// - Parameters:
24
+
/// - transferableValue: The value that will be attached to the output of
25
+
/// the test run.
26
+
/// - contentType: The content type with which to export `transferableValue`.
27
+
/// If this argument is `nil`, the testing library calls [`exportedContentTypes(_:)`](https://developer.apple.com/documentation/coretransferable/transferable/exportedcontenttypes(_:))
28
+
/// on `transferableValue` and uses the first type the function returns
29
+
/// that conforms to [`UTType.data`](https://developer.apple.com/documentation/uniformtypeidentifiers/uttype-swift.struct/data).
30
+
/// - preferredName: The preferred name of the attachment to use when saving
31
+
/// it. If `nil`, the testing library attempts to generate a reasonable
32
+
/// filename for the attached value.
33
+
/// - sourceLocation: The source location of the call to this initializer.
34
+
/// This value is used when recording issues associated with the
35
+
/// attachment.
36
+
///
37
+
/// - Throws: Any error that occurs while exporting `transferableValue`.
38
+
///
39
+
/// Use this initializer to create an instance of ``Attachment`` from a value
40
+
/// that conforms to the [`Transferable`](https://developer.apple.com/documentation/coretransferable/transferable)
41
+
/// protocol.
42
+
///
43
+
/// ```swift
44
+
/// let menu = FoodTruck.menu
45
+
/// let attachment = try await Attachment(exporting: menu, as: .pdf)
46
+
/// Attachment.record(attachment)
47
+
/// ```
48
+
///
49
+
/// When you call this initializer and pass it a transferable value, it
// This source file is part of the Swift.org open source project
3
+
//
4
+
// Copyright (c) 2026 Apple Inc. and the Swift project authors
5
+
// Licensed under Apache License v2.0 with Runtime Library Exception
6
+
//
7
+
// See https://swift.org/LICENSE.txt for license information
8
+
// See https://swift.org/CONTRIBUTORS.txt for Swift project authors
9
+
//
10
+
11
+
#if canImport(CoreTransferable)
12
+
publicimport Testing
13
+
publicimport CoreTransferable
14
+
15
+
privateimport Foundation
16
+
import UniformTypeIdentifiers
17
+
18
+
/// A wrapper type representing transferable values that can be attached
19
+
/// indirectly.
20
+
///
21
+
/// You do not need to use this type directly. Instead, initialize an instance
22
+
/// of ``Attachment`` using an instance of a type conforming to the [`Transferable`](https://developer.apple.com/documentation/coretransferable/transferable)
0 commit comments