Creating an image format with an unknown type is an error

My app uses a UIImagePickerController to allow the user to choose an image from their camera roll. This was all working fine up to iOS 9.3.4, but the iOS 10 betas now generate this error after the user has selected and tapped an image thumbnail from the picker: "[Generic] Creating an image format with an unknown type is an error". My picker is set to show kuTypeImage mediaTypes, but that's all I can think of doing.



I've added some NSLogs in the code for when the picker is displayed, and for when the user has selected an image in the imagePickerController:didFinishPickingMediaWithInfo: method. However, the error seems to be generated as soon as the image is selected, but before the picker is dismissed, so it appears before the imagePickerController:didFinishPickingMediaWithInfo: method.



Does anyone know how to fix this? As it stands, the image the user selectes is NOT returned to the method, so I can't use it.



I'm using iOS 10 beta 5 and Xcode 8 beta 5.



Here's the code:

- (void)showImageChooser
{
  UIImagePickerController *picker = [[UIImagePickerController alloc] init];
  [picker setDelegate:self];
  [picker setModalPresentationStyle:UIModalPresentationFullScreen];
  [picker setSourceType:UIImagePickerControllerSourceTypePhotoLibrary];
  [picker setAllowsEditing:NO];
  [picker setMediaTypes:[[NSArray alloc] initWithObjects:(NSString *)kUTTypeImage, nil]];
  self.imagePickerController = picker;

  NSLog(@"Presenting imagePicker");
  [self presentViewController:self.imagePickerController animated:YES completion:NULL];
  NSLog(@"imagePicker presented");
}



- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
  NSLog(@"didFinishPickingMediaWithInfo");
  UIImage *image = [info objectForKey:UIImagePickerControllerOriginalImage];

  / Do stuff with the image...

  [picker dismissViewControllerAnimated:YES completion:nil];
}


Thanks.

A newer version of Xcode was released on 15th September. It's build 8A218a. You can get it in the Mac App Store. Seems to have fixed my issue, but added a new problem in that I can't submit app updates because iTunes Connect thinks it's a beta.

I'm also using Xcode Version 8.0 (8A218a) and had the same issue. During development as I followed the now outdated instructions at Start Developing iOS Apps (Swift), Xcode flagged func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject]) as nearly matching a parent method, suggesting only that I make my override a private function to avoid this warning. Changing AnyObject to Any as suggested in this thread fixed the problem but was not among the suggestions listed by Xcode autocomplete. Xcode just needs to be polished here so that it suggests the right fix in this context.

Had the same issue and noticed that I changed the "AllowsEdititing" to NO.


If so try this:


- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
   
    UIImage *chosenImage = info[UIImagePickerControllerOriginalImage];
    imageViewPreview.image = chosenImage;
  
    [picker dismissViewControllerAnimated:YES completion:NULL];   
}

This works for me too but I still get 'Creating an image format with an unknown type is an error' in my debug log even though it doesn't prevent the app from working. I guess Swfit 3.0 and/or Xcode 8.0 (8A218a) just need polishing.

Thanks. this helped a lot! For anyone else following the Start Developing iOS Apps (Swift) guide,


the code in the guide:

func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : AnyObject])

should become:

func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any])


Make note that there is an underscore before picker:, and String : AnyObject is now String : Any.

This was an Objective-C issue, not a Swift issue, as has been explained a couple of times in the thread. Your solution cannot be used for my issue. This has also been mentioned in the thread.

Thanks, but that didn't work either. It seems that a simple recompile on the correct versions of Xcode fixed it.


(Despite my having downloaded and installed the FINAL GM RELEASE versions of macOS Sierra and Xcode 8 from the Mac App Store, they were broken. I had to reinstall both again, and it worked then.)

This works well! Thank you.

I get the error with Xcode 8.1


I cant add a teamID at the start, as Xcode says the app group must start with "group."


Does your solution still work in 8.1 for you?

Did you find any solution to this problem.

Having the exact same issue as OP..

Message still appears in XCode 8.2.1, but the image could be shown in imageview

I had the same issue in Objective-C with Xcode Version 8.2.1 (8C1002). I think it not a Xcode or Objective-C issue, Beacuse I found in my project' pch file import "NSDictionary+NilSafe.h", it can insert nil to NSDictionary and not crash.

Then I delete NSDictionary+NilSafe.h from my project, it works. Not Crash any longer.

Creating an image format with an unknown type is an error
 
 
Q