Build failed: ld: duplicate character _OBJC_CLASS _ $ _ Algebra5FirstViewController

I get this error all of a sudden when launching my application using iPhone simulator:

clang: error: the linker command worked with exit code 1 (use -v to see the Call):

ld: duplicate the _OBJC_CLASS symbol _ $ _ Algebra5FirstViewController in ... / Algebra5-anwcuftojtxtgkfootneeeqhwztj / Build / intermediates / Algebra5.build / Debug-iphonesimulator / Algebra5.build / Algebra5.build / iView5 / irol and Controls i005 iBuild -anwcuftojtxtgkfootneeeqhwztj / Build / intermediates / Algebra5.build / Debug-iphonesimulator / PSLE ​​Algebra5.build/Objects-normal/i386/PSLE_Algebra5FirstViewController.o for i386 architecture

What's the matter?

+71
ios objective-c xcode
May 03 '12 at 16:08
source share
28 answers

It seems that the Algebra5FirstViewController class compiles several times.

Can you make sure that .m and .mm are included only once in project sources in Xcode? You can also confirm this by checking the compilation log (the last icon on the right, next to the breakpoint icon) and make sure it is only compiled once.

Also, if this class is part of the library you are referring to, and you have a class with the same name, you may have the same error.

Finally, you can try to clean and rebuild, just in case the old object files are still present and there is unwanted information in the compiled files. Just in case...

EDIT

I also note that the second link is made in a file for ExercisesViewController. There may be something in this file. Either you #imported the Algebra5FirstViewController file instead of .h, or ExercisesViewController has @implementation (Algebra5FirstViewController) instead of @implementation (ExercisesViewController), or there was some trash with this file that would be cleaned using Clean a Rebuild.

+67
May 03 '12 at 16:13
source share

This can happen if the same .m file is referenced several times in the target section “Compile Sources” in the “Phase Assembly” section. Delete the duplicate entries and you should be fine.

+51
May 03 '12 at 16:14
source share

this problem also occurred, declaring const * NSString in the header file (wrong) instead of the implementation file (right)

+30
Jul 11 '12 at 19:37
source share

I have this problem because I accidentally imported .m instead of .h. Hope reading this saves someone with the same problem for a while.

+24
Jul 01 '13 at 19:46
source share

I had the same problem. Got this solution!

If you imported any files into the project, then check the .m (main) file for the same one as in Targets (Project Name) → Build Phases → Compile Sources.

If the file does not exist, enable it using the (+) Add button. Also, if duplicate files exist (if any), delete them.

Now press cmd + shift + k to clear the project. New Build should not display this error.

enter image description here

+10
Feb 05
source share

I got a similar error when adding files from another project, for example @paiego. My mistake was that I did not check "Add to targets." As explained above, I removed the links and added the files again, but this time the check "Add to targets."

+5
Oct. 16
source share

I had a similar error, and I solved it.

Try setting Build Active Architecture only to NO for the Pods project and the purpose of your application

+4
Dec 14 '15 at 11:56
source share

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

+3
Aug 25 2018-12-12T00:
source share

I met him when importing ViewController.m into TableViewController. Try to remove "#import" ViewController.m "if it came out. Hope this help!

+3
Oct 13 '14 at 11:05
source share

'failed to execute the linker command with exit code 1 (use -v to call the call)' - I got this error when launching the phone call application on the iPhone. I changed Build Active Architecture to Yes, and it worked just fine.

+1
Mar 28 '13 at 9:10
source share

It seems that for m I dragged the files into the project and after that it didn’t work, I clicked on the file “add files to the project”. Both were the wrong approach. just drag it to the projects folder (in finder), which contains other .h and .m files.

+1
Jan 13 '14 at 22:52
source share

after i got

 18 duplicate symbols for architecture i386 clang: error: linker command failed with exit code 1 

For me, this was due to the fact that I used "const NSInteger" in my switch case.

What I did was change the NSInteger constant for the enum and replace the reference to the enum values.

This fixed the bug for me.

+1
Apr 16 '14 at 5:53
source share

This happens either, some files are missing in the Compilation Sources section, or duplicate entries were found for some files. In my case, I had duplicate entries for two files, I deleted one entry for each of the files that solved my problem. Hope this helps.

+1
Jun 18 '14 at 6:32
source share

I found this article which provided me with a solution. It refers to Xcode 7, where the default value for No Common Blocks is Yes, and No in previous versions.

This is a quote from an article:

The problem is that "No shared blocks" in "Apple LLVM 6.1 -" Code Generation "in the" Build Settings "panel is set to" Yes "in the latest version of Xcode.

This caused what I will describe as circular links, where the class that was included in my compilation sources was specified via #import in another source file (appDelegate.m). This caused block duplication for variables that were declared in the original base class.

Changing the None value immediately disabled my application to compile and fix my problem.

+1
Sep 20 '15 at 13:52
source share

I am posting a new answer to this question because I ran into this error and had to use a different solution, which, it seems to me, relates to iOS 9.

I had to explicitly disable the "Enable Bitcode in Build Settings" option, which is automatically enabled in the update.

Answer: New warnings in iOS 9

+1
Oct. 14 '15 at 0:19
source share

[UPDATE XCODE 7.1]

The first option that worked:

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

Hope this helps someone.

UPDATE (Day 2) : The second time I will be back here in 2 days.

On the second day, I started getting more errors in addition to this annoying error. The problem was a conflicting file that Xcode did not recognize. I used the links below as a reference:

  • "_OBJC_CLASS_ $ _ viewsampleViewController" referenced by:

  • 'ld: warning: directory not found for option

And ultimately:

  1. "_OBJC_CLASS_ $ _ viewsampleViewController" referenced by:

I removed everything from FrameWork Search Paths + Compile Resources + Run Script Phases + pods and then installed them again to ultimately find success.

The problem with my size (on day 2) was rather a problem with conflicting files or files that Xcode did not recognize.

But ultimately, deleting everything (mentioned above and in the links), repeatedly clearing and reinstalling the pods / frameworks / run script phases helped.

Hope this helps someone.

+1
Nov 27 '15 at 14:10
source share

Running Xcode 4.6.3 on OSX 10.7.5 was able to fix this error by changing the architecture to the native architecture of the build machine from $ (NATIVE_ARCH_ACTUAL).

0
Jan 17 '14 at 19:12
source share

I got this once (by accident) by importing .h and .m files into one class.

0
Apr 28 '14 at 20:55
source share

I got this error when implementing a subclass without adding the added infrastructure (MPMoviePlayerController without MediaPlayer framework, in this example)

0
Aug 01
source share

I had the same problem when working with Bolts.framework. It turns out that when the Bolts are damaged, no re-import will fix the problem. I had to go back to the original download file and reimport completely from scratch. This immediately fixed it. It was such a strange problem that it took me endlessly to figure it out ... I hope this advice will spare some of you the same disappointments :)

0
Oct 22 '14 at 10:40
source share

This happened for me when I called the UILabel link and the same thing, I didn’t get an error when I typed it only when I tried to start it, so I didn’t understand that this is a problem, but if you have something something like a label, which is a "count", and you call it a count, and also call an int, which is also evaluated, this problem occurs.

0
Jul 21 '15 at 2:03
source share

Variations to this problem may occur if you have a missing library or file. Make sure there are no missing files in Project Explorer: they will be written in red if Xcode cannot find them.

0
May 4 '17 at 1:01
source share

"Link Binary With Libraries" has a library of old projects. Fixed after uninstall.

  • List item
  • Project
  • Build Phases
  • Link to binary files with libraries
  • Delete obsolete library.
0
May 8 '17 at 6:43
source share

I had the same problem with the library and I tried all the answers listed here and nothing helped.

In the end, I just removed the library from Link Binary With Libraries, and then re-added it , and it worked perfectly.

0
May 28 '17 at 9:05 a.m.
source share

The only (and unchanged) way to solve this problem is to create a test from the command line:

 xcodebuild -workspace MyProject.xcworkspace/ -scheme MyScheme -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 7,OS=10.3.1' test 

So, at this point, your compilation will probably fail, but you will see the whole binding problem. In my case, I had several problems, such as:

  • ld: 'Foo' framework not found
    To solve this problem, you need to configure the targets, BuildSettings-> Linking-> OtherLinkerFlags and remove the Foo infrastructure.
  • Use of unresolved identifier 'ClassName'.
    To solve this problem, I need to add / check the membership of the target file member in the target UITest.

Other possible problems will arise with xcodebuild, and you can easily fix it.

0
Jun 22 '17 at 11:33
source share

Just clearing CMD + SHIFT + K , then CMD + B worked for me.

0
Aug 01 '17 at 19:13
source share

In my case, I had a link to the library in other Linker flags. Removing from it got rid of the error.

enter image description here

enter image description here

-one
Oct 15 '16 at 15:43
source share

I had the same error. I imported audio frame work that I no longer used. I deleted it (DO NOT REMOVE THIS!), And it worked successfully.

-5
Jan 23 '13 at 11:32
source share



All Articles