user1374408
user1374408

Reputation: 321

Linker command failed with exit code 1 error in Xcode project

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.

Upvotes: 14

Views: 68053

Answers (21)

Wissa
Wissa

Reputation: 1592

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

Upvotes: 0

Yuchao Zhou
Yuchao Zhou

Reputation: 1072

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

Upvotes: 0

M. Black
M. Black

Reputation: 353

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

Upvotes: 0

Ishaan Gupta
Ishaan Gupta

Reputation: 11

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

enter image description here

Upvotes: -2

NIranjan Gajipara
NIranjan Gajipara

Reputation: 21

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.

Upvotes: 0

Florian
Florian

Reputation: 336

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.

Upvotes: 0

Surjeet Rajput
Surjeet Rajput

Reputation: 1301

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.

Upvotes: 0

BrianHenryIE
BrianHenryIE

Reputation: 559

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.

Upvotes: 3

Thyselius
Thyselius

Reputation: 954

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

Upvotes: 2

user441058
user441058

Reputation: 1278

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.

Upvotes: 0

Tala
Tala

Reputation: 19

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

Upvotes: 0

ScottyB
ScottyB

Reputation: 2497

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

Upvotes: 2

Florian-Rh
Florian-Rh

Reputation: 807

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.

Upvotes: 0

Narendra Ojha
Narendra Ojha

Reputation: 683

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.

Upvotes: 22

Christina
Christina

Reputation: 1

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.

Upvotes: 0

user1374408
user1374408

Reputation: 321

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.

Upvotes: 4

shri
shri

Reputation: 874

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.

Upvotes: 1

Vatsal Shukla
Vatsal Shukla

Reputation: 1272

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"

Upvotes: 0

Dan
Dan

Reputation: 5173

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.

Upvotes: 7

Dashzaki
Dashzaki

Reputation: 568

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.

Upvotes: 4

CodaFi
CodaFi

Reputation: 43330

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.

Upvotes: 26

Related Questions