Skip to content

Conversation

@grynspan
Copy link
Contributor

@grynspan grynspan commented Jul 7, 2025

This PR creates a platform-agnostic type to represent image formats for image attachments instead of relying directly on UTType. The implementation still requires UTType on Apple platforms, but on non-Apple platforms we can use the same type to represent those platforms' platform-specific image format enums (e.g. on Windows, it can box CLSID.) This reduces the platform-specific API surface area for image attachments.

Checklist:

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

… on `UTType`.

This PR creates a platform-agnostic type to represent image formats for image attachments instead of relying directly on `UTType`. The implementation still requires `UTType` on Apple platforms, but on non-Apple platforms we can use the same type to represent those platforms' platform-specific image format enums (e.g. on Windows, it can box `CLSID`.) This reduces the platform-specific API surface area for image attachments.
@grynspan grynspan added this to the Swift 6.x (main) milestone Jul 7, 2025
@grynspan grynspan self-assigned this Jul 7, 2025
@grynspan grynspan added the public-api Affects public API label Jul 7, 2025
@grynspan grynspan added the attachments/activities 🖇️ Work related to attachments and/or activities label Jul 7, 2025
@grynspan
Copy link
Contributor Author

grynspan commented Jul 7, 2025

@swift-ci test

// the preferred name's path extension.
let pathExtension = (preferredName as NSString).pathExtension
if !pathExtension.isEmpty,
let contentType = UTType(filenameExtension: pathExtension, conformingTo: .image),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to self: on Windows, ImageCodecInfo::FilenameExtension should help us here. Windows does not have hierarchical type declarations (does it?)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pointer to a null-terminated string that contains all file-name extensions associated with the codec. The extensions are separated by semicolons.

@grynspan grynspan merged commit f4379f5 into main Jul 8, 2025
3 checks passed
@grynspan grynspan deleted the jgrynspan/image-format-lowered branch July 8, 2025 20:16
@grynspan grynspan added the image-attachments 📸 Work related to image attachments label Aug 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

attachments/activities 🖇️ Work related to attachments and/or activities image-attachments 📸 Work related to image attachments public-api Affects public API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants