I'm working with a custom exported type in my macOS app when I found that SwiftUI's ShareLink
would not display any options for sharing.
Currently, I have a type that conforms to public.data
and public.json
, with a unique identifier and file extension too.
Here's a screenshot of the empty share sheet:
:
After searching through the documentation on Uniform Type Identifiers, I found this written about the content type:
For document types, conform to public.content, either directly or by conforming to a type that already conforms to public.content. This conformance allows users to share your type over AirDrop.
This seems to be not true in my context, so I assume that I have made a mistake.
Here's my current Transferable
conformance:
extension Quote: Transferable { static var transferRepresentation: some TransferRepresentation { CodableRepresentation(contentType: .quote) }}extension UTType { // Real type identifier is not com.example, of course static var quote: UTType { UTType(exportedAs: "com.example.quote") }}
These are the declarations of exported type identifiers and document types in my Xcode project settings:
.
This is what the ShareLink
looks like:
ShareLink( item: Quote(text: "In a galaxy far far away..."), preview: SharePreview("An intersting quote"), label: { Image(systemName: "square.and.arrow.up") })
Does anyone know why this issue of having no Share Options is occurring with this custom exported type identifier?