I am creating a UIDocumentPicker extension on iOS for the first time. I have populated the UIDocumentPickerExtensionViewController
subclass with its appropriate methods. In my UI when the user selects the document from my extension, I am able to successfully copy the image in question to the document directory. Relevant code:
NSURL *sourceURL = [item imageUrlWithPath:image.fullSizeImagePath];
NSString *filename = [NSString stringWithFormat:@"%@.jpg", item.title ?: NSLocalizedString(@"NO_TITLE", nil)];
NSURL *targetURL = [self.documentStorageURL URLByAppendingPathComponent:filename];
NSError *copyError = nil;
BOOL success = [fm copyItemAtURL:sourceURL toURL:targetURL error:©Error];
if (success) {
[self dismissGrantingAccessToURL:targetURL];
} else {
NSLog(@"Error! %@", copyError);
}
This all goes fine according to the code path above, however, after the selection is made and the call is made to dismissGrantingAccessToURL:
, the UI gets dismissed, but I get an alert from the host application (in this case, Pages) saying that the image could not be inserted because "This image is of an unsupported type."
Things I have tried:
- Try the file name with a different file extension
- Used variations of different thumbnails of my image
- Recompressed the image to a new file.
All to no avail. How come my file cannot be read by other applications?