build failed with: ld: duplicate symbol _OBJC_CLAS

2019-01-02 18:05发布

I am getting this error suddenly when running my app via iPhone simulator:

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

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

What is it all about?

28条回答
心情的温度
2楼-- · 2019-01-02 18:33

I was getting similar error and I got it resolved this way.

Try to set Build Active Architecture Only to NO for 'Pods' project and your app's target

查看更多
步步皆殇っ
3楼-- · 2019-01-02 18:33

This occurred for me when I named a UILabel reference and an int the same thing, I didn't get an error when I typed it only when I tried to run it so I didn't realize that that was the problem, but if you have something like a label which is the "score" and you call it score, and name an int which is the score also score then this problem occurs.

查看更多
不流泪的眼
4楼-- · 2019-01-02 18:34

I got this issue because I accidentally imported the .m instead of the .h. Hope reading this saves someone with same problem some time.

查看更多
旧人旧事旧时光
5楼-- · 2019-01-02 18:34

[XCODE 7.1 UPDATE]

First Option That Worked:

I changed the Deployment Target from 7.1 to 8.1 and the error went away.

Hope that helps someone.

UPDATE (day 2): Second time I'm back here in 2 days.

On day 2 I started to get more errors in addition to this annoying error. The problem was a conflicting file that Xcode didn't recognize. I used the links below as help:

  1. "_OBJC_CLASS_$_viewsampleViewController", referenced from:

  2. ‘ld: warning: directory not found for option’

And ultimately:

  1. "_OBJC_CLASS_$_viewsampleViewController", referenced from:

I was deleting everything from the FrameWork Search Paths + Compile Resources + Run Script Phases + the pods and then re-installing them again to ultimately find success.

The issue on my size (on day 2) was more of a problem with conflicting files or files that Xcode didn't recognize.

But ultimately, removing everything (mentioned above and in the links), cleaning a lot of times and reinstalling the pods/frameworks/run script phases helped.

Really hope this helps someone.

查看更多
梦寄多情
6楼-- · 2019-01-02 18:36

In one case, I saw this error when dragging a new class' .h and .m into the project. The only solution I found was to remove the references to these files and then add them back via the project menu.

查看更多
梦该遗忘
7楼-- · 2019-01-02 18:38

'linker command failed with exit code 1 (use -v to see invocation)'- I got this error when running a phonegap application on iPhone. I changed Build Active Architecture Only to Yes and it worked fine.

查看更多
登录 后发表回答