I have an IOSurface
and I want to turn that into a CIImage
. However, the constructor of CIImage
takes a IOSurfaceRef
instead of a IOSurface
.
On most platforms, this is not an issue because the two types are toll-free bridgeable... except for Mac Catalyst, where this fails.
I observed the same back in Xcode 13 on macOS. But there I could force-cast the IOSurface
to a IOSurfaceRef
:
let image = CIImage(ioSurface: surface as! IOSurfaceRef)
This cast fails at runtime on Catalyst.
I found that unsafeBitCast(surface, to: IOSurfaceRef.self)
actually works on Catalyst, but it feels very wrong.
Am I missing something? Why aren't the types bridgeable on Catalyst?
Also, there should ideally be an init
for CIImage
that takes an IOSurface
instead of a ref.