简体   繁体   English

Xcode中的链接器命令失败

[英]linker command failed in Xcode

I was building an app, but later on I quickly changed something(a value in char variable) and tried to load again, now I am getting this error 我正在构建一个应用程序,但后来我迅速更改了某些内容(char变量中的值),并尝试再次加载,现在出现此错误

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

I have undone what I have done, but still I am getting this error. 我已经撤消了所做的事情,但是仍然出现此错误。 I have tried to delete build folder, it did not work... I also performed clean and build but still it cannot build... 我试图删除构建文件夹,但没有用...我也执行了清理和构建,但仍然无法构建...

You have to check the files included in the build. 您必须检查构建中包含的文件。 Quite possibly there are some duplicate implementation (or perhaps header?) files included. 可能包括一些重复的实现(或头文件?)文件。

  1. Navigate to {Project} > {Target} > Build Phases . 导航至{Project} > {Target} > Build Phases
  2. Check the Compile Sources build phase for duplicates. 检查“ Compile Sources构建阶段是否存在重复项。
  3. Remove all duplicate files. 删除所有重复的文件。

Also make sure no duplicate libraries are included in the project. 还要确保项目中没有重复的库。 You may check this in the Link Binary With Library phase. 您可以在Link Binary With Library阶段中进行检查。 Basically same story as above, but for libraries. 与上述基本相同,但适用于图书馆。

Finally make sure to clean the project before building ( Product > Clean ). 最后,请确保在构建之前清洁项目( Product > Clean )。

My error message was a little different - duplicate symbols ... in ClassImplmentationFile. 我的错误消息有些不同-ClassImplmentationFile中的重复符号...。 m

I didn't have any of the duplicates, as described above, but I noticed that the .m files that were listed in the error message, were in Build Phases/ Compile Sources. 如上所述,我没有任何重复项,但是我注意到错误消息中列出的.m文件位于“构建阶段/编译源”中。

I removed them from there and the thing ran fine. 我从那里将它们移开,一切运行正常。

I didn't put them in there. 我没有把它们放在那里。 I guess Xcode auto-screwed-up my project at some point. 我想Xcode会在某个时候自动完成我的项目。 : - ) :-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM