I had the same issue using the share sheet in UIKit. The workaround was to save the image to the file system and present the file URL of this image to the share sheet.
It seems important to use an absolute URL:
guard let url = imageURL?.absoluteURL else { … }
Using a relative URL appeared to create two issues:
Sometimes the given file name e.g. "1.jpg" could be changed to a different (system supplied name) containing a UUID.
When running as an "iOS App on Mac" the share sheet provided a copy option that seemed to fail when presented with a relative URL.