[Pitch] Transferable Attachments

This proposal extends the Swift Testing Attachments API (previous discussion: [Pitch] Attachments) with support for the Transferable protocol from Apple's system CoreTransferable framework (Core Transferable | Apple Developer Documentation).

Swift Testing already provides first-class attachment support for types conforming to NSSecureCoding and Encodable, offering a default serialization path that lets values be attached to a test with minimal boilerplate. Transferable fills a similar role โ€” it defines a flexible, declarative way to serialize Swift values into data blobs or files, and many system-provided types across Apple platforms already conform to it.

With the built-in Transferable support alongside the existing NSSecureCoding and Encodable support, test authors gain the ability to attach a much broader set of types โ€” including many system types โ€” without any additional serialization code.

Full proposal: ST-NNNN `Transferable` Attachments by aronskaya ยท Pull Request #3155 ยท swiftlang/swift-evolution ยท GitHub

10 Likes

This sounds very useful to make testing things like drag&drop, AppIntents and share functionality easier. Especially if IDEs are also aware of it / support it.

My main question would be: does this need to be part of Swift Testing, or can it also be shipped within CoreTransferable itself? Especially as the protocol is defined in the CoreTransferable package itself, maybe it should also provide this test helper?

Most likely you already thought about this. Then perhaps its good to add it to the "alternatives considered" section.

1 Like

From a technical standpoint, it needs to be a cross-import overlay, but it could "ship" with either framework. The benefit of doing it in Swift Testing is it gets to be open-source code!

This pitch has now advanced to formal review.