Xcode错误“重复符号”导致了Apple Mach-O链接错误。

时间:2022-06-07 14:44:56
duplicate symbol _leagueTableLoaded in:
/Users/Brendan/Library/Developer/Xcode/DerivedData/2013-dbhrwzgxgwhfbqatgqpfrmqyucyu/Build/Intermediates/2013.build/Debug-iphonesimulator/2013.build/Objects-normal/i386/LTGlobalResultsViewController.o

/Users/Brendan/Library/Developer/Xcode/DerivedData/2013-dbhrwzgxgwhfbqatgqpfrmqyucyu/Build/Intermediates/2013.build/Debug-iphonesimulator/2013.build/Objects-normal/i386/LTJumpToMeViewController.o

duplicate symbol _showGLobalCompany in:

/Users/Brendan/Library/Developer/Xcode/DerivedData/2013-dbhrwzgxgwhfbqatgqpfrmqyucyu/Build/Intermediates/2013.build/Debug-iphonesimulator/2013.build/Objects-normal/i386/LTGlobalResultsViewController.o

/Users/Brendan/Library/Developer/Xcode/DerivedData/2013-dbhrwzgxgwhfbqatgqpfrmqyucyu/Build/Intermediates/2013.build/Debug-iphonesimulator/2013.build/Objects-normal/i386/LTJumpToPositionViewController.o

duplicate symbol _leagueTableLoaded in:

/Users/Brendan/Library/Developer/Xcode/DerivedData/2013-dbhrwzgxgwhfbqatgqpfrmqyucyu/Build/Intermediates/2013.build/Debug-iphonesimulator/2013.build/Objects-normal/i386/LTGlobalResultsViewController.o

/Users/Brendan/Library/Developer/Xcode/DerivedData/2013-dbhrwzgxgwhfbqatgqpfrmqyucyu/Build/Intermediates/2013.build/Debug-iphonesimulator/2013.build/Objects-normal/i386/LTJumpToPositionViewController.o

ld: 3 duplicate symbols for architecture i386

clang: error: linker command failed with exit code 1 (use -v to see invocation)

I am getting the error above in xcode only when I try to build in simulator (on any iOS device I can build without error). I have three classes:

只有当我试图在模拟器上构建时,我才会在xcode中得到上述错误(在任何我可以毫无错误地构建的iOS设备上)。我有三个类:

1.LTGlobalResultsViewController 2.LTJumpToMeViewController 3.LTJumpToPositionViewController

1。LTGlobalResultsViewController 2。3. LTJumpToMeViewController ltjumptopositionviewcontroller

All three were created in xcode but both 2 & 3 have been modified outside of xcode and then rebuilt.

这三个都是在xcode中创建的,但是2和3都在xcode之外进行了修改,然后重新构建。

The @property bool leagueTableLoaded is defined in the header for all three. it is declared as:

@property bool leagueTableLoaded在所有三个的头中定义。这是声明为:

@property bool leagueTableLoaded;

What is it exactly that is causing this error? I have tried the following:

到底是什么导致了这个错误?我试过以下几点:

  1. I have tried renaming leagueTableLoaded in different classes but this doesn't fix it.

    我尝试过在不同的类中重新命名leaguetablelode,但这并没有解决它。

  2. I have tried deleting my Derived Data files manually in library/developer/xcode folder.

    我尝试在库/developer/xcode文件夹中手动删除我的派生数据文件。

  3. According to other questions I have checked if I am importing a .m file. This is not the case. Apple Mach-O Linker error ("duplicate symbol")

    根据其他问题,我检查了是否导入了。m文件。事实并非如此。Apple Mach-O链接错误(“重复符号”)

Any other suggestions or advice? Thanks, James

还有其他建议或建议吗?谢谢你,詹姆斯

ADDITION: As requested please find all the extracts from my .h and .m files that reference leagueTableLoaded or any of the variants I created when trying to get round this error:

另外:根据请求,请从我的.h和.m文件中找到所有引用leagueTableLoaded的文件或我在试图解决这个错误时创建的任何变量:

LTJumpToMeViewController.h
@property bool leagueTableLoadedMe;

LTJumpToMeViewController.m
@implementation LTJumpToMeViewController
bool leagueTableLoaded = false;

LTGlobalResultsViewController.h
@property bool globalLeagueTableLoaded;

LTGlobalResultsViewController.m
@implementation LTGlobalResultsViewController
bool leagueTableLoaded = false;

LTJumpToPositionViewController.h
@property bool leagueTableLoadedPos;

LTJumpToPositionViewController.m
@implementation LTJumpToPositionViewController
bool leagueTableLoaded = false;

I can provide more information if required!

如果需要,我可以提供更多的信息!

4 个解决方案

#1


6  

For me a duplicate symbol error came up when I absent mindedly included a .m file instead of a .h (Why does Xcode's autosuggest even show me .m files?!)

对于我来说,一个重复的符号错误出现在我心不在焉地包含一个。m文件而不是。h(为什么Xcode的自动建议甚至显示给我。m文件?!)

#2


0  

In this end this was being caused by the leagueTableLoaded bool being defined in both LTGlobalResultsViewController.m and LTJumpToPositionViewController.m.

在这端,这是由在LTGlobalResultsViewController中定义的leaguetablelotedbool引起的。m和LTJumpToPositionViewController.m。

Removing it from one of them fixed the issue. Although I'm not sure why it was there in the first place! Hope this helps anyone else who experiences the same issue! James

把它从其中一个解决了。虽然我不知道为什么它会出现在第一个地方!希望这能帮助其他经历同样问题的人!詹姆斯

#3


0  

Xcode error “Duplicate Symbol” causing Apple Mach-O Linker Error is caused by duplicate symbols in Project. Steps to avoid error

Xcode错误“重复符号”导致Apple Mach-O链接错误是由项目中的重复符号引起的。措施以避免错误

  1. Go to project -> Target ->Build Phases ->Compile sources
  2. Go to project ->目标->构建阶段->编译源。
  3. Check for the duplicate file (implementation file)
  4. 检查复制文件(实现文件)
  5. Delete the file and add it again
  6. 删除该文件并再次添加它。
  7. Clean and run project again
  8. 再次清理和运行项目。

This worked for me. Hope it helps

这为我工作。希望它能帮助

#4


0  

In second view controller, you mistakenly #import "First.m", check it must be first.h file so replaces this with first.h. It's working for me.

在第二个视图控制器中,您错误地输入“第一个”。i’,检查一下。h文件用first。h代替。这对我的工作。

#1


6  

For me a duplicate symbol error came up when I absent mindedly included a .m file instead of a .h (Why does Xcode's autosuggest even show me .m files?!)

对于我来说,一个重复的符号错误出现在我心不在焉地包含一个。m文件而不是。h(为什么Xcode的自动建议甚至显示给我。m文件?!)

#2


0  

In this end this was being caused by the leagueTableLoaded bool being defined in both LTGlobalResultsViewController.m and LTJumpToPositionViewController.m.

在这端,这是由在LTGlobalResultsViewController中定义的leaguetablelotedbool引起的。m和LTJumpToPositionViewController.m。

Removing it from one of them fixed the issue. Although I'm not sure why it was there in the first place! Hope this helps anyone else who experiences the same issue! James

把它从其中一个解决了。虽然我不知道为什么它会出现在第一个地方!希望这能帮助其他经历同样问题的人!詹姆斯

#3


0  

Xcode error “Duplicate Symbol” causing Apple Mach-O Linker Error is caused by duplicate symbols in Project. Steps to avoid error

Xcode错误“重复符号”导致Apple Mach-O链接错误是由项目中的重复符号引起的。措施以避免错误

  1. Go to project -> Target ->Build Phases ->Compile sources
  2. Go to project ->目标->构建阶段->编译源。
  3. Check for the duplicate file (implementation file)
  4. 检查复制文件(实现文件)
  5. Delete the file and add it again
  6. 删除该文件并再次添加它。
  7. Clean and run project again
  8. 再次清理和运行项目。

This worked for me. Hope it helps

这为我工作。希望它能帮助

#4


0  

In second view controller, you mistakenly #import "First.m", check it must be first.h file so replaces this with first.h. It's working for me.

在第二个视图控制器中,您错误地输入“第一个”。i’,检查一下。h文件用first。h代替。这对我的工作。