iOS未定义的体系结构i386符号:“_ kUTTypeImage”

时间:2012-12-20 16:15:12

标签: ios xcode uiimagepickercontroller linker-errors

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

我正在为我的应用添加一个UIImagePickerController,当我去编译时,我得到了上面的错误。我在SO上找到了一个解决方案:

Symbol not found: kUTTypeImage

  

查找符号(kUTTypeImage)并找到它应该存在的图像/库(在本例中为MobileCoreServices.framework)。然后将二进制文件与该框架链接起来。

问题是,我不确定如何实现它。如何查找符号然后将其链接到框架?

应该注意到我已经导入了MobileCoreServices框架。这是相关的代码:

if ([UIImagePickerController isSourceTypeAvailable:
                 UIImagePickerControllerSourceTypeCamera]) {

                UIImagePickerController* myCamera = [[UIImagePickerController alloc] init];
                myCamera.delegate = self;
                myCamera.sourceType = UIImagePickerControllerSourceTypeCamera;
                myCamera.mediaTypes = [NSArray arrayWithObjects:(NSString *) kUTTypeImage, nil];
                myCamera.allowsEditing = NO;
                [self presentModalViewController:myCamera animated:YES];

            }

enter image description here

enter image description here

1 个答案:

答案 0 :(得分:6)

您只需要添加然后将框架导入项目(或者更确切地说,目标)。在导航器中,单击您的项目,然后选择目标。然后转到Build Phases选项卡,如果它尚未展开,请展开Link Binary With Libraries。然后添加MobileCoreServices.framework。在要使用kUTTypeImage的文件中,添加以下导入:

#import <MobileCoreServices/MobileCoreServices.h>

请注意,您通常使用尖括号(&lt;&gt;)而不是引号。