14

I was working on my project and suddenly after editing the code and compiling gave this error:

ld: warning: directory not found for option '-
L/Users/mani/Documents/Classes/Twitter+OAuth/Libraries & Headers' ld: duplicate symbol _OBJC_CLASS_$_playSiew in /Users/mani/Library/Developer/Xcode/DerivedData/learn-aktrtiwswclovoatyweyquoxmypa/Build/Intermediates/learn.build/Debug-iphonesimulator/learn.build/Objects-normal/i386/playSiew.o and /Users/mani/Library/Developer/Xcode/DerivedData/learn-aktrtiwswclovoatyweyquoxmypa/Build/Intermediates/learn.build/Debug-iphonesimulator/learn.build/Objects-normal/i386/Thumb.o for architecture i386 clang: error: linker command failed with exit code 1 (use -v to see invocation)

I never touched the project settings, just edited the code.

What's more strange is that I took out last revised code from svn but still I got the the same error.

6
  • 2
    There may be some ivars which you have declared in your playSiew.m file and with the same name you have declared in another .m file.May be this helps you cause i have also faced this duplicate symebol error and it did the trick for me Commented May 30, 2012 at 6:36
  • but why I am facing this error now? I never had this problem before and it suddenly appeared? Commented May 30, 2012 at 6:40
  • Check you import statement, seems like you have imported two library which has same named symbol Commented May 30, 2012 at 6:47
  • 1
    I think u have changed the code from the location.so that refference is not there i think that is causing the problem Commented May 30, 2012 at 12:26
  • Similar issue, I found stackoverflow.com/questions/33499570/xcode-duplicate-symbol Commented Nov 4, 2015 at 7:29

21 Answers 21

26

You may be accidentally #import'ing a .m file instead of a .h. Use Cmd+Shift+F and search for ".m" (without quotes). It will most likely lie in one of the classes mentioned in the warning. If not, clean and run again.

Sign up to request clarification or add additional context in comments.

2 Comments

as I said....the previous revised code in svn is also not working...so definately its not a problem with code. Moreover the same code in which I am facing problem is running fine on my team member's mac
actually searching for .m" (with the ending quote) might help to find it faster
22

I was also having same issue and I did following and issue is gone.

Go to Product -> Clean and re-run the project.

I hope it might be useful for some other developers.

1 Comment

I found the same thing. Always a good thing to try for a mysterious failure.
7

After running into this problem a few minutes ago (yes, I know it's been 7 months since the original thread) I found that the root of my issue was due to me dragging & dropping files into my project within XCode instead of right-clicking and choosing Add Files to Project.

1 Comment

Two years later...I always drag and drop image files into my project. I just had this happen and cleaning the project resolved it. Of course, since this is basically a dice roll error message who knows if that'll work for anyone else.
4

Check playSiew.m is in Compile Sources section. isn't it?

You can find Compile Sources section follow this step

  1. Select YourProjectName
  2. Select TARGETS
  3. Select Build Phases

If don't have playSiew.m in this section . You must to add it to this section.

Comments

4

As I said the problem wasn't the code but some settings. So what I did was copying the code from my friends' Mac (it was working fine), and installed a fresh copy of the project to my Mac. It worked.

Comments

3

I was importing a library in a test case which I had specified in my pod file for the main target but not for the test target.

1 Comment

Saved my life. I was thinking I missing import some files which added by other guys. But actually it was this, one lib in pod file move a place and not included in test target!
2

I also got this error because I had accidentally included two versions of the same source file. Deleted the wrong one and the problem went away...

Comments

2

If you're working in Unity and export to iOS and you are using a plugin, go to Xcode Build Settings and set ENABLE BITCODE = NO. I'm guessing this might apply to other situations as well

1 Comment

I too ran into this issue while building a Unity project, after I had added a compiler flag to a .m file in the Unity editor. I eventually noticed the message in the Unity editor that says: > "Once a native plugin is loaded from script, it's never unloaded. If you deselect a native plugin and it's already loaded, please restart Unity." After reading this, I restarted Unity and rebuilt the project, and the linker error went away.
1

Faced similar issue, while running the code on a simulator, tried all the above mentioned options, still got the same error. Tried connecting the iOS device and build the code, it worked for us. This can be a quick workaround.

Comments

0

the same error i faced. so, i just removed reference of that classes which are generating the errors and than again gave reference and the error was gone...

as D80Buckeye says there should be problem of dragging and dropping files instead of Clicking on "Add Files"

2 Comments

This does not really answer the question. If you have a different question, you can ask it by clicking Ask Question. You can also add a bounty to draw more attention to this question once you have enough reputation.
@Pinal , i tried my self with the same issue on Xcode 6.0.1. and with that trick the issue was solved so, i shared my experience. so it is really not the answer of that Question.
0

In case this comes in useful for anyone else--I just had this same error, and turns out the cause was initializing a variable in my header file rather than in the main file.

Comments

0

I just encountered the same error. If you are using embedded Libraries, make sure your Deployment Target is set to iOS 8.0 or higher.

Comments

0

you only need to add the following framework: quartzcore.framework

Comments

0

The only way we can get past this bug on our project is to do a Clean and then build for iPad Retina. After that it will build successfully for any device. Weird.

Comments

0

In my case i have add reference of FacebookLoginSDK framework but forget to give search path in build setting. After removing its reference everything was fine.

So conclusion is if you are adding any external framework be careful.

Comments

0

If this happens to you with CoreData generated classes, combine the +CoreDataProperties and +CoreDataClass into the +CoreDataProperties class and delete the +CoreDataClass. Make sure to search Derived Data for leftovers of the +CoreDataClass. Even after deleting the Derived Data and cleaning I sometimes had Xcode just generate the +CoreDataClass again and again. Deleting it manually in Finder and then re-bulding helped me solve this.

Comments

0

try this, go to Target -> Build Settings,then search these three as following,

GCC_NO_COMMON_BLOCKS,

CLANG_WARN_INFINITE_RECURSION,

CLANG_WARN_SUSPICIOUS_MOVE,

set NO to each value then clean and build.

Comments

0

I tried several of the answers listed but none worked for me. I got the error after updating XCode (while it was still open which may have contributed to the problem)

First, I deleted my Derived Data folder: XCode => Preferences => Locations => Double Click on arrow next to path indicating where the Derived Data folder is. Then "Move to Trash" I don't think that's what the problem was, but it's amazing how many times this has been an issue for me working on different problems.

Second, I 'Quit' the simulator.

Third, I 'Quit' XCode.

Fourth, I opened up my project in XCode again and then did a Clean and Build (found in the Product menu)

Fifth, I ran my project and it worked fine

Comments

0

Cleaning the project not works for me. Restart the Xcode works for me...

Comments

0

For me it was different. I had the same error when I removed a Pod and solved it by removing this pod from the Other Linker Flags in the Build Settings

enter image description here

then clean your project [Product > Clean] and rebuild

Comments

-2

Go to general and linked frameworks and libraries in xcode and remove all the files there.

enter image description here

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.