xcode 架构 armv7 错误的重复符号

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

duplicate symbols for architecture armv7 Error

iosxcodeswiftcore

提问by Maha

I have an old class "Approval.swift" in my swift project

我的 swift 项目中有一个旧类“Approval.swift”

I added NSManagedObject (Approval) in Core Data and i create NSManagedObject subclass with the same name (Approval.swift) for that entity

我在 Core Data 中添加了 NSManagedObject (Approval) 并为该实体创建了具有相同名称 (Approval.swift) 的 NSManagedObject 子类

Then i changed the Entity name to "ApprovalObject" and the associated class to ApprovalObject.swift to differentiate it from the old class "Approval.swift"

然后我将实体名称更改为“ApprovalObject”并将关联的类更改为 ApprovalObject.swift 以将其与旧类“Approval.swift”区分开来

When i tried to run the project, i got this error

当我尝试运行该项目时,出现此错误

duplicate symbol _OBJC_METACLASS_$_Card in: /Users/MyUser/Library/Developer/Xcode/DerivedData/MyProject-czluntwgoefegbeilusmojsyejlc/Build/Intermediates/MyProject.build/Debug-iphoneos/MyProject.build/Objects-normal/armv7/ApprovalObject.o /Users/MyUser/Library/Developer/Xcode/DerivedData/MyProject-czluntwgoefegbeilusmojsyejlc/Build/Intermediates/MyProject.build/Debug-iphoneos/MyProject.build/Objects-normal/armv7/Card.o duplicate symbol _OBJC_CLASS_$_Card in: /Users/MyUser/Library/Developer/Xcode/DerivedData/MyProject-czluntwgoefegbeilusmojsyejlc/Build/Intermediates/MyProject.build/Debug-iphoneos/MyProject.build/Objects-normal/armv7/ApprovalObject.o /Users/MyUser/Library/Developer/Xcode/DerivedData/MyProject-czluntwgoefegbeilusmojsyejlc/Build/Intermediates/MyProject.build/Debug-iphoneos/MyProject.build/Objects-normal/armv7/Card.o

ld: 2 duplicate symbols for architecture armv7 clang: error: linker command failed with exit code 1 (use -v to see invocation)

重复符号 _OBJC_METACLASS_$_Card 在:/Users/MyUser/Library/Developer/Xcode/DerivedData/MyProject-czluntwgoefegbeilusmojsyejlc/Build/Intermediates/MyProject.build/Debug-iphoneos/MyProject.build/Objects-normal/armv7/ApprovalObject.o /用户/MyUser/Library/Developer/Xcode/DerivedData/MyProject-czluntwgoefegbeilusmojsyejlc/Build/Intermediates/MyProject.build/Debug-iphoneos/MyProject.build/Objects-normal/armv7/Card.o 重复符号_OBJC_CLASS_$_Card 在:/Users /MyUser/Library/Developer/Xcode/DerivedData/MyProject-czluntwgoefegbeilusmojsyejlc/Build/Intermediates/MyProject.build/Debug-iphoneos/MyProject.build/Objects-normal/armv7/ApprovalObject.o /Users/MyUser/Library/Developer/Xcode /DerivedData/MyProject-czluntwgoefegbeilusmojsyejlc/Build/Intermediates/MyProject.build/Debug-iphoneos/MyProject.build/Objects-normal/armv7/Card.o

ld:架构 armv7 clang 的 2 个重复符号:错误:链接器命令失败,退出代码为 1(使用 -v 查看调用)

Can someone help me in solving this error? Thanks a lot

有人可以帮我解决这个错误吗?非常感谢

采纳答案by Buntylm

Duplicate symbols for architecturemainly reason is you have added the same .mor .ofile twice into your project. For resolving the issue just check the linker error like in your case its showing ApprovalObject. Then just go build phasesthen compile sourcesand search the specified file.

Duplicate symbols for architecture主要原因是您已将相同.m.o文件两次添加到您的项目中。为了解决这个问题,只需检查链接器错误,就像在你的情况下它显示的一样ApprovalObject。然后就去build phases然后compile sources搜索指定的文件。

回答by Alan Glasby

I was getting the same type of error with a newly created app under Xcode 8. After much investigation I found reference to entries under Build Phases -> Compile Sources where I found that the data model was included in addition to the .m files. Removing this cleared the error and the app now builds and functions correctly.

我在 Xcode 8 下使用新创建的应用程序遇到了相同类型的错误。经过大量调查后,我发现对 Build Phases -> Compile Sources 下的条目的引用,我发现除了 .m 文件之外还包含数据模型。删除它清除了错误,应用程序现在可以正确构建和运行。

回答by Joe M

I got the above build error because I imported a .m file instead of a .h file in another .m file

我收到上述构建错误是因为我在另一个 .m 文件中导入了 .m 文件而不是 .h 文件