Skip to content

Conversation

grynspan
Copy link
Contributor

@grynspan grynspan commented Sep 19, 2025

This PR explicitly marks the image attachments API bits in the core Swift Testing library as unavailable on e.g. Linux. Developers who attempt to use this API on Linux will get diagnostics such as:

🛑 'AttachableImageFormat' is unavailable: Image attachments are not available on this platform.

Blocked on #1329.

Checklist:

  • Code and documentation should follow the style of the Style Guide.
  • If public symbols are renamed or modified, DocC references should be updated.

…n and Windows.

This PR eliminates a bunch of duplicated code between Darwin and Windows that's
used to support image attachments. We're able to do this because
`_AttachableImageWrapper` is now a class and can be included in conforms-to
generic constraints, so we can write
`where AttachableValue: _AttachableImageWrapper<T> & AttachableWrapper`. It was
previously a structure and structures can't be used in generic constraints this
way.

There's a new public, underscored protocol introduced here, `_AttachableAsImage`,
that serves as a "base" protocol for `AttachableAsCGImage` and
`AttachableAsIWICBitmapSource`. I intend to promote this protocol to API, but it
will need a Swift Evolution proposal first. I'm going to include it in a future
"image attachments refinement" proposal that will cover a few other things.
@grynspan grynspan added this to the Swift 6.x (main) milestone Sep 19, 2025
@grynspan grynspan self-assigned this Sep 19, 2025
@grynspan grynspan added enhancement New feature or request linux 🐧 Linux support (all distros) embedded-swift 📟 Embedded Swift issues wasi/wasm 🧭 WebAssembly support android 🤖 Android support freebsd 😈 FreeBSD support attachments/activities 🖇️ Work related to attachments and/or activities qnx 🫐 QNX support playstation 🎮 PS4/PS5 support openbsd 🐡 OpenBSD support image-attachments 📸 Work related to image attachments labels Sep 19, 2025
This PR explicitly marks the image attachments API bits in the core Swift
Testing library as unavailable on e.g. Linux. Developers who attempt to use this
API on Linux will get diagnostics such as:

> 🛑 'AttachableImageFormat' is unavailable: Image attachments are not available on this platform.
@grynspan grynspan force-pushed the jgrynspan/mark-image-attachments-unavailable-on-other-platforms branch from 8a39992 to f3b39b9 Compare September 19, 2025 21:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
android 🤖 Android support attachments/activities 🖇️ Work related to attachments and/or activities embedded-swift 📟 Embedded Swift issues enhancement New feature or request freebsd 😈 FreeBSD support image-attachments 📸 Work related to image attachments linux 🐧 Linux support (all distros) openbsd 🐡 OpenBSD support playstation 🎮 PS4/PS5 support qnx 🫐 QNX support wasi/wasm 🧭 WebAssembly support
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant