Does NSImage not conform to _ObjectiveCBridgeable?

I want to check the contents of an NSItemProvider to validate a drop action in SwiftUI on macOS.

I use the code:

let urlProviders = info.itemProviders(for: [.url])
if urlProviders.filter({ $0.canLoadObject(ofClass: NSImage.self) }).some {
    return true
}

But I get the compilation error:

Instance method 'canLoadObject(ofClass:)' requires that 'NSImage' conform to '_ObjectiveCBridgeable'

Is this a bug? The same code works with UIImage when compiling for iOS.

Xcode 13.4

Post not yet marked as solved Up vote post of Gillies Down vote post of Gillies
687 views

Replies

The same problem!

Same issue here. Has anyone figured out a fix or a workaround for this?