Symbol not found: kUTTypeImage
Asked Answered
B

4

84

I copied some bits of code from apple's 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: The 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 post does not have much context to explain the code sections; please explain your scenario more clearly.

Boatswain answered 13/4, 2012 at 16:47 Comment(1)
(It wasn't your fault) I've read all the docs I can find on UIImagePickerController, they talk about using kUT* for mediaTypes, but in their sample code, they often just pass the values from one function to the array. They never actually use it in their code, and they don't mention that you need to import it.Smetana
K
202

Look up the symbol (kUTTypeImage) and locate the image/library it should exist in (MobileCoreServices.framework in this case). Then link your binary with that framework.

Kershaw answered 13/4, 2012 at 16:51 Comment(3)
Also do not forget to import the header <MobileCoreServices/MobileCoreServices.h>Oratorical
Worked! apparently I linked the CoreFoundation and not the MobileCoreServices.Boatswain
or put @import MobileCoreServices; if you don't want to import the framework and do all the nasty workEmbowel
F
50

Obligatory Swift answer:

import MobileCoreServices
Fructificative answered 24/7, 2016 at 22:49 Comment(0)
F
2

When use with UIDocumentPickerViewController do:

import MobileCoreServices

let type = String(kUTTypeImage)
let documentPickerViewController = UIDocumentPickerViewController(documentTypes: [type], in: .import)
Fresno answered 19/5, 2020 at 18:17 Comment(0)
U
2

For Swift it appears to be in

import UniformTypeIdentifiers

let type = String(describing: UTType.image)
Unhandsome answered 22/1, 2022 at 0:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.