Attempting to call an INImage initialiser raises NSInvalidArgumentException exception?

I'm trying to make a Siri extension (Visual Codes) domain and the response requires an INImage to be set. However, any call I make to the INImage class to create one results in an NSInvalidArgumentException crash. The error indicates the class does not actually implement the methods defined in its header. I'm a bit stymied as there is no way to respond to the Siri request correctly without creating an INImage.


Here's the console error:


*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[INImage imageWithCGImage:]: unrecognized selector sent to class 0x1b1c22390'


I am calling the API from Swift so that resulted from calling the INImage(cgImage:) initializer. However, I get the same class of error when trying to call of the INImage methods, including the class method INImage.imageSize(for:).


Please advise. Is this a bug and, if so, is there a workaround? I'm stumped.

Replies

I've stumbled upon the same bug while working on my iOS 14 widgets. My current workaround is to convert the UIImage into Data and use the init(imageData: Data) initializer.

Code Block
if let imageData = uiImage.pngData() {
let inImage = INImage(imageData: imageData)
...
}