14
votes

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.

21
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 mesuperGokuN
but why I am facing this error now? I never had this problem before and it suddenly appeared?user1374408
Check you import statement, seems like you have imported two library which has same named symbolTeaCupApp
I think u have changed the code from the location.so that refference is not there i think that is causing the problemhacker

21 Answers

27
votes

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.

22
votes

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.

7
votes

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.

4
votes

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.

4
votes

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.

3
votes

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.

2
votes

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...

2
votes

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
votes

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.

0
votes

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"

0
votes

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.

0
votes

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.

0
votes

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

0
votes

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.

0
votes

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.

0
votes

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.

0
votes

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.

0
votes

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

0
votes

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

0
votes

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

-2
votes

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

enter image description here