I was testing our application on new device with beta iOS 11 and found an intresting error. We are creating an image which can be saved to user gallery, using UIActivityViewController (some system share view controller):
NSMutableArray *sharingItems = [NSMutableArray new];
UIImage *screenShot = [self shareViewScreenShot];
NSString *filename = @"notImportant";
NSString *path = [NSString stringWithFormat:@"%@%@.jpg", NSTemporaryDirectory(), filename];
[UIImageJPEGRepresentation(screenShot, 1.0) writeToFile:path atomically:YES];
NSURL *pathUrl = [NSURL fileURLWithPath:path];
[sharingItems addObject:pathUrl];
UIActivityViewController *activityController = [[UIActivityViewController alloc] initWithActivityItems:sharingItems applicationActivities:nil];
[self presentViewController:activityController animated:YES completion:nil];
This works fine, presenting share dialog, until user press "save image". Then I got error about not suporting this image format
2017-07-19 10:51:54.292881+0200 appName[6632:766119] Video /private/var/mobile/Containers/Data/Application/29B8C33B-9247-45FE-B51F-A35A035019A9/tmp/notImportant.jpg cannot be saved to the saved photos album: Error Domain=AVFoundationErrorDomain Code=-11828 "Nie można otworzyć" UserInfo={NSUnderlyingError=0x1c08558d0 {Error Domain=NSOSStatusErrorDomain Code=-12847 "(null)"}, NSLocalizedFailureReason=Ten format multimediów nie jest obsługiwany., NSURL=file:///private/var/mobile/Containers/Data/Application/29B8C33B-9247-45FE-B51F-A35A035019A9/tmp/notImportant.jpg, NSLocalizedDescription=Nie można otworzyć}
The same happens when I use png/UIImagePNGRepresentation. So the questions are:
Are png/jpg supported in iOS 11?
Should I use/and how HEIF (new apple image format) for devices with os version >= 11?