I am implementing custom keyboard with only images and wanted to send images to textDocumentProxy/input controls like textview on click of image but not get over it. so far
Please try in a device, you can test with iMessage App in a device. Default input views like UITextView and UITextField do not support the images. They only support the strings.
The following code will copy the image into the pasteboard.
let pb = UIPasteboard.generalPasteboard()
let image: UIImage = UIImage(named: imgArray[indexPath.row])!
let imgData: NSData = UIImagePNGRepresentation(image)!
pb.setData(imgData, forPasteboardType: kUTTypePNG as String)
And give "Allow Full Access" for keyboard in settings. And add the RequestsOpenAccess to YES in the info.plist file.