mach-o链接器错误重复符号。标头中没有导入的.m文件或​​声明

时间:2014-08-10 19:49:33

标签: ios xcode mach-o

我在Xcode的项目中遇到错误。我一直在取得良好的进展,到目前为止,一切都进展顺利。在对我的应用程序中的一个页面进行一些微妙的布局更改后,在尝试运行它时 - 我得到一个mach-o链接器错误,说明多个(266!)重复的符号。

到目前为止,我有:

  • 多次通过代码以确保我没有导入任何.m文件(我没有)
  • 确保头文件中没有声明(没有)
  • 检查应用内不同类别中的重复符号,即使在.m文件中也不应该共享(没有任何内容)
  • 清理项目(没有欢乐)
  • 重新启动Xcode
  • 尝试在多个模拟器和真实设备上运行(同样的错误仍然存​​在)
  • 删除派生数据(感谢提示Reinhard,如下面的注释) - 打开管理器(Window - > Organizer(shift-cmd-2) - > projects - >删除派生数据)。不幸的是,即使在清理和重建之后,错误也会再次发生。
  • 检查项目导航器中支持文件文件夹中的.pch(预编译头文件)文件 - 仍然没有任何乐趣!

我在这个和其他网站上看了很多类似的帖子,到目前为止,大多数错误似乎都是人们导入实现文件时的错误。当我过去遇到类似的错误时,通过代码来解决它们相当容易 - 通常它是不同类中的重复变量。这一次,我尽力将事情尽可能地封装起来,到目前为止我还没有在这个项目中遇到过这个问题。

我现在就在这里发布错误信息。该代码现已发布在https://github.com/bentaylor42/iRSI的GitHub上,因为它太长而无法放在此页面上。

    Ld /Users/bentaylor/Library/Developer/Xcode/DerivedData/irsi-acrjzbjeyiktwpglrdrfvwhlnhql/Build/Products/Debug-iphonesimulator/irsi.app/irsi normal i386
cd "/Users/bentaylor/Dropbox/iRSI v2/irsi"
export IPHONEOS_DEPLOYMENT_TARGET=7.1
export PATH="/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Applications/Xcode.app/Contents/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator7.1.sdk -L/Users/bentaylor/Library/Developer/Xcode/DerivedData/irsi-acrjzbjeyiktwpglrdrfvwhlnhql/Build/Products/Debug-iphonesimulator -F/Users/bentaylor/Library/Developer/Xcode/DerivedData/irsi-acrjzbjeyiktwpglrdrfvwhlnhql/Build/Products/Debug-iphonesimulator -filelist /Users/bentaylor/Library/Developer/Xcode/DerivedData/irsi-acrjzbjeyiktwpglrdrfvwhlnhql/Build/Intermediates/irsi.build/Debug-iphonesimulator/irsi.build/Objects-normal/i386/irsi.LinkFileList -Xlinker -objc_abi_version -Xlinker 2 -fobjc-arc -fobjc-link-runtime -Xlinker -no_implicit_dylibs -mios-simulator-version-min=7.1 -framework AudioToolbox -framework AVFoundation -framework QuartzCore -framework CoreGraphics -framework UIKit -framework Foundation -Xlinker -dependency_info -Xlinker /Users/bentaylor/Library/Developer/Xcode/DerivedData/irsi-acrjzbjeyiktwpglrdrfvwhlnhql/Build/Intermediates/irsi.build/Debug-iphonesimulator/irsi.build/Objects-normal/i386/irsi_dependency_info.dat -o /Users/bentaylor/Library/Developer/Xcode/DerivedData/irsi-acrjzbjeyiktwpglrdrfvwhlnhql/Build/Products/Debug-iphonesimulator/irsi.app/irsi

duplicate symbol _OBJC_IVAR_$_MainMenuViewController._labelVersion in:
/Users/bentaylor/Library/Developer/Xcode/DerivedData/irsi-acrjzbjeyiktwpglrdrfvwhlnhql/Build/Intermediates/irsi.build/Debug-iphonesimulator/irsi.build/Objects-normal/i386/MainMenuViewController-9C9455DB49A1DC98.o
duplicate symbol _OBJC_IVAR_$_MainMenuViewController._labelCopyright in:
/Users/bentaylor/Library/Developer/Xcode/DerivedData/irsi-acrjzbjeyiktwpglrdrfvwhlnhql/Build/Intermediates/irsi.build/Debug-iphonesimulator/irsi.build/Objects-normal/i386/MainMenuViewController-9C9455DB49A1DC98.o
duplicate symbol _OBJC_IVAR_$_MainMenuViewController._switchPHEM in:
/Users/bentaylor/Library/Developer/Xcode/DerivedData/irsi-acrjzbjeyiktwpglrdrfvwhlnhql/Build/Intermediates/irsi.build/Debug-iphonesimulator/irsi.build/Objects-normal/i386/MainMenuViewController-9C9455DB49A1DC98.o
duplicate symbol _OBJC_IVAR_$_MainMenuViewController._labelPHEM in:
/Users/bentaylor/Library/Developer/Xcode/DerivedData/irsi-acrjzbjeyiktwpglrdrfvwhlnhql/Build/Intermediates/irsi.build/Debug-iphonesimulator/irsi.build/Objects-normal/i386/MainMenuViewController-9C9455DB49A1DC98.o

//... and so on, for 266 duplicated symbols, across multiple classes throughout the app)

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

1 个答案:

答案 0 :(得分:1)

您在Compile Sources中有许多重复的.m文件,将它们从名为" irs​​i"的目标中删除,之后,您应该成功编译。 enter image description here

顺便说一下,我认为你也应该从你的项目中删除重复的引用,我在下面的图片中列出了一些。

enter image description here