本文介绍了添加NSManagedObject子类,重复链接时出现重复的符号错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Xcode中自动创建NSManagedObject子类(2个相关实体)。它们是这样生成的:

I was trying to create NSManagedObject subclasses (2 related entities) automatically in Xcode. They are generated like this:

然而,在我做任何事情之前,当我尝试构建并运行它时,会发生链接错误,如图所示:

However, before I do anything further, when I tried to build and run it, a link error occur, as shown:


重复符号_OBJC_CLASS _ $ _照片输入:
/ Users / Kefeng / Library / Developer / Xcode / DerivedData / Photomania-aellrakjngugnzcgrleiytvrfvyt / Build / Intermediates / Photomania。 build / Debug-iphonesimulator / Photomania.build / Objects-normal / x86_64 / Photo + CoreDataClass.o
重复符号_OBJC_METACLASS _ $ _照片输入:
/ Users / Kefeng / Library / Developer / Xcode / DerivedData / Photomania -aellrakjngugnzcgrleiytvrfvyt / Build / Intermediates / Photomania.build / Debug-iphonesimulator / Photomania.build / Objects-normal / x86_64 / Photo + CoreDataClass.o
复制符号_OBJC_CLASS _ $ _摄影:
/ Users / Kefeng /图书馆/开发商/ Xcode中/ DerivedData / Photomania-aellrakjngugnzcgrleiytvrfvyt /编译/中间体/ Photomania.build / d ebug-iphonesimulator / Photomania.build / Objects-normal / x86_64 / Photography + CoreDataClass.o
复制符号_OBJC_METACLASS _ $ _摄影:
/ Users / Kefeng / Library / Developer / Xcode / DerivedData / Photomania-aellrakjngugnzcgrleiytvrfvyt /Build/Intermediates/Photomania.build/Debug-iphonesimulator/Photomania.build/Objects-normal/x86_64/Photography+CoreDataClass.o
ld:4个用于体系结构的重复符号x86_64
clang:error:linker命令退出代码1失败(使用-v查看调用)

我尝试了多次创建新项目并执行一样。我的初衷是将一些自定义方法添加到子类中。但是当我添加任何内容时,例如照片+ CoreData.h / m ,出现与上面相同的错误。

I tried several times by creating new projects and do the same thing. My original intention is to add some custom methods into those to subclasses. But when I add anything into e.g. Photo+CoreData.h/m, the same error as above showed up.

我找到了一些关于双重包含或将文件保存到错误的目录,但我没有这样做。有人对此有任何想法吗?

I found some answers about the "double include" or "save files to the wrong directory", but I didn't do that. Anybody have any idea about this?

推荐答案

如果您没有自动生成托管对象子类,那么不要忘记检查实体中的Codegen设置数据模型检查员:

If you do not generate managed object subclass automatically, then don't forget to check "Codegen" settings for an Entity in Data Model Inspector:

这篇关于添加NSManagedObject子类,重复链接时出现重复的符号错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-24 10:55