多次尝试修复错误:链接器命令失败,退出代码为1

时间:2016-03-16 14:34:29

标签: objective-c xcode linker-errors

过去几天我一直在处理这个错误,我真的被卡住了。我一直收到链接器命令错误,无法通过它。我搜索了网页并尝试了所有提示:检查重复文件,重新安装的pods,将活动架构设置为NO,删除派生数据,清理很多次。

这是我给出的输出:

duplicate symbol _OBJC_IVAR_$_SessionPlayer._nextEvent in:
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayer.o
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayerViewController.o
duplicate symbol _OBJC_IVAR_$_SessionPlayer._visitors in:
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayer.o
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayerViewController.o
duplicate symbol _OBJC_IVAR_$_SessionPlayer._currentSessionTimeInMilliseconds in:
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayer.o
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayerViewController.o
duplicate symbol _OBJC_IVAR_$_SessionPlayer._systemTimeInMilliseconds in:
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayer.o
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayerViewController.o
duplicate symbol _OBJC_CLASS_$_SessionPlayer in:
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayer.o
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayerViewController.o
duplicate symbol _OBJC_METACLASS_$_SessionPlayer in:
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayer.o
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayerViewController.o
duplicate symbol _OBJC_IVAR_$_SessionPlayer._isPlaying in:
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayer.o
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayerViewController.o
duplicate symbol _OBJC_IVAR_$_SessionPlayer._useTiming in:
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayer.o
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayerViewController.o
duplicate symbol _OBJC_IVAR_$_SessionPlayer._delegate in:
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayer.o
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayerViewController.o
duplicate symbol _OBJC_IVAR_$_SessionPlayer._timeline in:
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayer.o
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayerViewController.o

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

真的不知道该怎么做,这非常令人沮丧。

编辑:发现我的所有文件都被编译了两次,这可能就是问题所在。

1 个答案:

答案 0 :(得分:3)

听起来你已经在你的目标构建中包含了SessionPlayer.m两次的来源。根据一些评论,可能是因为您通过pod(这是您想要的)隐式引用文件,并通过直接引用显式 / included(你不想想要的;那是pod的用途)。尝试执行以下操作(我会尽量在文本中尽可能清楚,但如果您有任何问题我可以包含屏幕截图):

  1. 在项目导航器窗格中,选择您的项目。
  2. 在项目编辑器窗口中,选择您的应用目标(确保它不像UnitTest / LogicTest目标)。
  3. 在项目编辑器窗口的顶部,选择" Build Phases"
  4. 在主项目编辑器窗口中,现在应该有一个可扩展部分列表,其中一个是"编译源(xxx项)",其中xxx是用于构建的源文件数你的目标。展开该部分。
  5. 在搜索/过滤器文本字段(项目编辑器的右上角,占位符文本显示"过滤器")中,输入" SessionPlayer"
  6. 我怀疑您已明确包含SessionPlayer.m,因此您应该在列表中看到至少一个实例。选择" - "删除它显示在列表底部的按钮。
  7. 尝试重建并查看至少与SessionPlayer.m相关的链接器错误是否消失。如果是,请对任何其他此类文件重复上述步骤。
  8. 希望这有帮助。