xcode 架构 i386 的 iOS 未定义符号:“_kUTTypeImage”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13976220/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-15 02:22:40  来源:igfitidea点击:

iOS Undefined symbols for architecture i386: "_kUTTypeImage"

iosxcodeuiimagepickercontrollerlinker-errors

提问by PruitIgoe

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)

I'm adding a UIImagePickerController to my app and when I go to compile I get the above error. I found a solution on SO:

我正在向我的应用程序添加一个 UIImagePickerController,当我进行编译时,出现上述错误。我在 SO 上找到了解决方案:

Symbol not found: kUTTypeImage

未找到符号:kUTTypeImage

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.

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

Problem is, I'm not sure how to implement it. How do I look up the symbol and then link it to the framework?

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

Should of noted I already have the MobileCoreServices framework imported. Here's the relevant code:

应该注意的是,我已经导入了 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

在此处输入图片说明

回答by Scott Berrevoets

You only need to add and then import the framework into your project (or rather, target). In the Navigator, click on your project, and select a target. Then go to the Build Phases tab and, if it's not expanded already, expand Link Binary With Libraries. Then add MobileCoreServices.framework. In the file you want to use kUTTypeImage, add this import:

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

#import <MobileCoreServices/MobileCoreServices.h>

#import <MobileCoreServices/MobileCoreServices.h>

Note that you use angle brackets (<>) and not quotes as you would normally.

请注意,您使用尖括号 (<>) 而不是像通常那样使用引号。