Character not found: kUTTypeImage

I copied some code snippets from the apple documentation - and I got these 2 errors:

Undefined symbols for architecture i386: "_kUTTypeImage", referenced from: -[ImagePicker imagePickerController:didFinishPickingMediaWithInfo:] in ImagePicker.o ld: symbol(s) not found for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation) 

What am I doing wrong?

EDIT: Code:

 - (IBAction) showSavedMediaBrowser { [self startMediaBrowserFromViewController: self usingDelegate: (id)self]; } - (BOOL) startMediaBrowserFromViewController: (UIViewController*) controller usingDelegate: (id <UIImagePickerControllerDelegate, UINavigationControllerDelegate>) delegate { if (([UIImagePickerController isSourceTypeAvailable: UIImagePickerControllerSourceTypeSavedPhotosAlbum] == NO) || (delegate == nil) || (controller == nil)) return NO; UIImagePickerController *mediaUI = [[UIImagePickerController alloc] init]; mediaUI.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum; // Displays saved pictures and movies, if both are available, from the // Camera Roll album. mediaUI.mediaTypes = [UIImagePickerController availableMediaTypesForSourceType: UIImagePickerControllerSourceTypeSavedPhotosAlbum]; // Hides the controls for moving & scaling pictures, or for // trimming movies. To instead show the controls, use YES. mediaUI.allowsEditing = YES; mediaUI.delegate = delegate; [controller presentViewController:mediaUI animated:YES completion:nil]; return YES; } - (void) imagePickerController: (UIImagePickerController *) picker didFinishPickingMediaWithInfo: (NSDictionary *) info { NSString *mediaType = [info objectForKey: UIImagePickerControllerMediaType]; UIImage *originalImage, *editedImage, *imageToUse; // Handle a still image picked from a photo album if (CFStringCompare ((__bridge_retained CFStringRef) mediaType, kUTTypeImage, 0) == kCFCompareEqualTo) { editedImage = (UIImage *) [info objectForKey: UIImagePickerControllerEditedImage]; originalImage = (UIImage *) [info objectForKey: UIImagePickerControllerOriginalImage]; if (editedImage) { imageToUse = editedImage; } else { imageToUse = originalImage; } // Do something with imageToUse } [[picker parentViewController] dismissModalViewControllerAnimated: YES]; } 

I think the error is where the last method starts, but I'm not sure.

Your message does not have much context for explaining sections of code; Explain your script more clearly.

+70
ios objective-c linker-errors
Apr 13 2018-12-12T00:
source share
3 answers

Find the symbol ( kUTTypeImage ) and find the image / library in which it should exist ( MobileCoreServices.framework in this case). Then link your binary to this framework.

+183
Apr 13 2018-12-12T00:
source share

Mandatory Swift answer:

 import MobileCoreServices 
+22
Jul 24 '16 at 22:49
source share

import MobileCoreServices

This works for me. Import is necessary for iOS 10, and not for the next version.

0
Apr 15 '19 at 7:25
source share



All Articles