import SwiftUI extension Image { init(data: Data) { #if canImport(AppKit) self.init(nsImage: NSImage(data: data) ?? .init()) #elseif canImport(UIKit) self.init(uiImage: UIImage(data: data) ?? .init()) #else EmptyView() #endif } }