问题描述
我在通过 iPhone 模拟器运行我的应用程序时突然收到此错误:
I am getting this error suddenly when running my app via iPhone simulator:
clang: 错误:链接器命令失败,退出代码为 1(使用 -v 查看调用):
ld:重复符号 _OBJC_CLASS_$_Algebra5FirstViewController.../Algebra5-anwcuftojtxtgkfootneeeqhwztj/Build/Intermediates/Algebra5.build/Debug-iphonesimulator/Algebra5.build/Objects-normal/i386/ExercisesViewController.o和.../Algebra5-anwcuftojtxtgkfootneeeqhwztj/Build/Intermediates/Algebra5.build/Debug-iphonesimulator/PSLEAlgebra5.build/Objects-normal/i386/PSLE_Algebra5FirstViewController.o对于架构 i386
ld: duplicate symbol _OBJC_CLASS_$_Algebra5FirstViewController in .../Algebra5-anwcuftojtxtgkfootneeeqhwztj/Build/Intermediates/Algebra5.build/Debug-iphonesimulator/Algebra5.build/Objects-normal/i386/ExercisesViewController.o and .../Algebra5-anwcuftojtxtgkfootneeeqhwztj/Build/Intermediates/Algebra5.build/Debug-iphonesimulator/PSLE Algebra5.build/Objects-normal/i386/PSLE_Algebra5FirstViewController.o for architecture i386
这是关于什么的?
推荐答案
看起来像 Algebra5FirstViewController 类被多次编译.
It look like the class Algebra5FirstViewController is compile multiple time.
您能否确保 .m 和 .mm 在 Xcode 的项目源中只包含一次?您也可以通过检查编译日志(右侧最后一个图标,断点图标旁边)来确认这一点,并确认它仅编译一次.
Can you make sure that the .m and .mm is only included once in your project sources in Xcode? You can also confirm this by checking in the compile log (last icon at the right, next to the breakpoints icon) and see that confirm that it is only compiled once.
此外,如果此类是您链接的库的一部分,并且您有一个同名的类,则可能会出现相同的错误.
Also, if this class is part of a library that you link against and you have a class with the same name, you could have the same error.
最后,您可以尝试清理和重建,以防旧的目标文件仍然存在并且编译文件中有一些垃圾.以防万一...
Finally, you can try a clean and rebuild, just in case the old object files are still present and there is some junk in the compiled files. Just in case...
编辑
我还注意到,第二个引用是在文件中针对ExtractionsViewController 进行的.也许这个文件里有东西.要么你 #imported Algebra5FirstViewController 文件而不是 .h,或者 ExercisesViewController 有 @implementation (Algebra5FirstViewController) 而不是 @implementation (ExercisesViewController),或者这个文件中有一些垃圾,将使用 Clean an Rebuild 清理.
I also note that the second reference is made in the file for ExercisesViewController. Maybe there is something in this file. Either you #imported the Algebra5FirstViewController file instead of the .h, or the ExercisesViewController has @implementation (Algebra5FirstViewController) instead of @implementation (ExercisesViewController), or there was some junk with this file that will cleaned with a Clean an Rebuild.
这篇关于构建失败:ld:重复符号 _OBJC_CLASS_$_Algebra5FirstViewController的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!