重复的符号错误

Rob*_*ill 7 xcode objective-c

我不知道我做了什么,但我添加了一个IBOutlet来在TableView单元格中显示一个额外的属性.构建应用程序时,我收到以下错误消息...

Ld /Users/roberthill/Library/Developer/Xcode/DerivedData/PHAInspect-awfhtfopjdgfmsdsjfjivdnlzgir/Build/Products/Debug-iphonesimulator/PHAInspect.app/PHAInspect normal i386
    cd /Users/roberthill/Documents/PHAInspect
    setenv MACOSX_DEPLOYMENT_TARGET 10.6
    setenv PATH "/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
    /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.0.sdk -L/Users/roberthill/Library/Developer/Xcode/DerivedData/PHAInspect-awfhtfopjdgfmsdsjfjivdnlzgir/Build/Products/Debug-iphonesimulator -F/Users/roberthill/Library/Developer/Xcode/DerivedData/PHAInspect-awfhtfopjdgfmsdsjfjivdnlzgir/Build/Products/Debug-iphonesimulator -filelist /Users/roberthill/Library/Developer/Xcode/DerivedData/PHAInspect-awfhtfopjdgfmsdsjfjivdnlzgir/Build/Intermediates/PHAInspect.build/Debug-iphonesimulator/PHAInspect.build/Objects-normal/i386/PHAInspect.LinkFileList -mmacosx-version-min=10.6 -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -Xlinker -no_implicit_dylibs -D__IPHONE_OS_VERSION_MIN_REQUIRED=50000 -framework CoreData -framework UIKit -framework Foundation -framework CoreGraphics -o /Users/roberthill/Library/Developer/Xcode/DerivedData/PHAInspect-awfhtfopjdgfmsdsjfjivdnlzgir/Build/Products/Debug-iphonesimulator/PHAInspect.app/PHAInspect

ld: duplicate symbol _OBJC_METACLASS_$_Inspection in /Users/roberthill/Library/Developer/Xcode/DerivedData/PHAInspect-awfhtfopjdgfmsdsjfjivdnlzgir/Build/Intermediates/PHAInspect.build/Debug-iphonesimulator/PHAInspect.build/Objects-normal/i386/Inspection-AEDA73D75B42426A.o and /Users/roberthill/Library/Developer/Xcode/DerivedData/PHAInspect-awfhtfopjdgfmsdsjfjivdnlzgir/Build/Intermediates/PHAInspect.build/Debug-iphonesimulator/PHAInspect.build/Objects-normal/i386/Inspection-AEDA73D75B42426A.o for architecture i386
Command /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/clang failed with exit code 1
Run Code Online (Sandbox Code Playgroud)

我尝试退出更改以添加IBOutlet但我仍然收到此错误消息.

我检查了其他类似的帖子,但我不认为条件是相同的(虽然我可能是错的).有任何想法吗?

qua*_*rac 51

我有一个类似的问题:

ld: duplicate symbol _OBJC_METACLASS_$_MyClass1 in /Users/.../MyClass2.o and /Users/.../MyClass1.o for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Run Code Online (Sandbox Code Playgroud)

最后的原因是我在MyClass2.m里写道:

#include "MyClass1.m"
Run Code Online (Sandbox Code Playgroud)

代替

#include "MyClass1.h"
Run Code Online (Sandbox Code Playgroud)

当你的.m文件中有很多#include语句时很难找到.


jus*_*tin 20

当源在目标中编译两次,或者它是在两个单独的目标中构建时,可能会发生这种情况.您可以在目标的构建阶段验证这一点,或者从目标中删除它,然后重新添加它.

更新

Kasas指出了一个新的Xcode功能(在其他评论者拒绝的编辑中),Xcode可以为您检测一些此类情况 - 只需"验证"目标或项目设置.如果找到,Xcode将为您提供删除冗余编译.谢谢卡萨斯.


Rob*_*oll 11

除.m问题外,如果您在错误的文件夹中创建模型,则删除它们,然后在正确的文件夹中创建/替换模型.您可能需要删除Compiled Sources分组下的Targets Build Phases中的重复项.


dre*_*kka 1

不确定,但这是一个愚蠢的问题 - 清除旧代码后您是否进行了清理?有时那些东西会挂在身边。