Xcode 链接器错误:_OBJC_CLASS_$_CIImage

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/2976294/
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-14 19:25:23  来源:igfitidea点击:

Xcode Linker error: _OBJC_CLASS_$_CIImage

objective-ccocoaxcode

提问by Adam

When building my Xcode project I am receiving a Linker error that I cannot figure out how to resolve. If I build the following code the compile step completes just fine but I get an error from the Linker saying '"_OBJC_CLASS_$_CIImage", referenced from Objc-class-ref-to-CIImage in AppController.o' followed by a second error that looks identical except CIImage is replaced with CIFilter followed by a statement that says "Symbol(s) not found"

在构建我的 Xcode 项目时,我收到一个链接器错误,我不知道如何解决。如果我构建以下代码,编译步骤完成得很好,但我从链接器那里得到一个错误,说“_OBJC_CLASS_$_CIImage”,从 AppController.o 中的 Objc-class-ref-to-CIImage 引用',然后是第二个错误看起来完全相同,除了 CIImage 被 CIFilter 替换,后跟一个说“找不到符号”的语句

CIFilter *transform = [CIFilter filterWithName:@"CIAffineTransform"];
[transform setValue:inputBitmap forKey:@"inputImage"];
NSAffineTransform *affineTransform = [NSAffineTransform transform];
[affineTransform rotateByDegrees:3];
[transform setValue:affineTransform forKey:@"inputTransform"];
CIImage * result = [transform valueForKey:@"outputImage"];

This code is in my AppController.m, and the Linker error showed up after I put the following statement up at the top:

这段代码在我的 AppController.m 中,在我将以下语句放在顶部后出现链接器错误:

#import "QuartzCore/CIFilter.h"

I put that import statement in because, without it I get a Compiler error on the first line of code that says "No +filterWithName method found" and I read somewhere that Cocoa automatically includes CIImage.h but not CIFilter.h. So ... with the #import the compiler error disappears but I get the linker error. :(

我把那个导入语句放进去是因为,如果没有它,我会在第一行代码中得到一个编译器错误,上面写着“没有找到 +filterWithName 方法”,我在某处读到 Cocoa 自动包含 CIImage.h 但不包含 CIFilter.h。所以......使用#import,编译器错误消失,但我收到链接器错误。:(

Any ideas what is causing the Linker error and how to get rid of it?

任何想法是什么导致链接器错误以及如何摆脱它?

FYI: I tried searching for duplicate files as described in another "xcode linker error" thread herein, but could not find any duplicate files in my project. I also went to the trouble to create a completely new Project, and copy all my code from the old project to the new one, just to eliminate the possibility that I had somehow accidentally corrupted my project files. I still have the same issue in my new project.

仅供参考:我尝试按照此处的另一个“xcode 链接器错误”线程中的描述搜索重复文件,但在我的项目中找不到任何重复文件。我还费心地创建了一个全新的项目,并将我所有的代码从旧项目复制到新项目,只是为了消除我以某种方式不小心损坏了项目文件的可能性。我在我的新项目中仍然有同样的问题。

Thanks

谢谢

回答by Sukhi

Add "CoreImage" framework.

添加“CoreImage”框架。

(Well, I know this question is old. But I had a same problem and adding "QuartzCore" framwork didn't help it).

(好吧,我知道这个问题很老。但我遇到了同样的问题,添加“QuartzCore”框架并没有帮助它)。

回答by Wevah

Make sure you've added the QuartzCore framework to your project (Linked Frameworks)!

确保您已将 QuartzCore 框架添加到您的项目(链接框架)中!