diff --git a/Packages/ComposeUI/Sources/ComposeUI/CoreData/DraftAttachment.swift b/Packages/ComposeUI/Sources/ComposeUI/CoreData/DraftAttachment.swift index 0def2175..64ecf945 100644 --- a/Packages/ComposeUI/Sources/ComposeUI/CoreData/DraftAttachment.swift +++ b/Packages/ComposeUI/Sources/ComposeUI/CoreData/DraftAttachment.swift @@ -157,10 +157,11 @@ extension DraftAttachment: NSItemProviderReading { var data = data var type = UTType(typeIdentifier)! - // this seems to only occur when the item is a UIImage, rather than just image data, - // which seems to only occur when sharing a screenshot directly from the markup screen + // the type is .image in certain circumstances: + // - macOS: image copied from macOS Safari -> only UIImage(data: data) works + // - iOS: sharing screenshot from markup -> only NSKeyedUnarchiver works if type == .image, - let image = try? NSKeyedUnarchiver.unarchivedObject(ofClass: UIImage.self, from: data), + let image = UIImage(data: data) ?? (try? NSKeyedUnarchiver.unarchivedObject(ofClass: UIImage.self, from: data)), let pngData = image.pngData() { data = pngData type = .png