Linker command error: 'ld: symbol(s) not found for architecture i386'
Asked Answered
I

11

25

I have an error at compile time. Seems to be weird. it worked as detail view application, but using single view doesn't seem to work. this is the error details:

   Undefined symbols for architecture i386:
    "_OBJC_CLASS_$_RssArticle", referenced from:
      objc-class-ref in RssXmlParser.o
  ld: symbol(s) not found for architecture i386
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
Innoxious answered 19/7, 2012 at 3:13 Comment(0)
D
57

Try these steps:

  1. Open your project in XCode.

  2. In left side window/panel of XCode click on your project name on top.

  3. Now select Target from right side panel of XCode.

  4. Select Build Phases from right panel's top. (here other option will be Build Settings, Build Rules)

  5. In the same panel open the "Compile sources", here check: are all the files (.m) listed? if not all files click on (+) sign in bottom to add (.m) files which is not in list

  6. As per your error it seems RssXmlParser not there, add this and compile again

It will work fine now.

Donothingism answered 19/7, 2012 at 5:57 Comment(4)
What version of X-Code does this work for? I can't seem to find Target on the right side...Jolinejoliotcurie
@iOSTest I ran into the same issue. I want to know why does this happen, though.Redundant
Also check what you exactly subclassing your class!Unfrequented
for me in Xcode 8.3.3, Under Build Phases > Compile Sources i had some extra .m files that were not associated with the project i was working on and just removed them to solve the linker command failed with exit code 1 errorChanty
D
27

don't see anybody suggesting to go to terminal and go to the directory where the project is and run

xcodebuild -verbose

to see detailed error and just reading the error helps a lot of the time

Duotone answered 14/1, 2017 at 1:41 Comment(1)
this is not exactly an answer but still this+selected answer helped me solve my issue! Personally, I had two plugins .m files (served the same purpose) in the list of .m files. I removed one and built it again and that solved the problem.Starflower
F
13

I realized I had to use the .xcworkspace file instead of the .xcodeproj file.

Fingernail answered 5/3, 2015 at 19:13 Comment(2)
This worked just fine for me, but I'd also like to know why. Any explanation?Cowling
One reason when you should use .xcworkspace is when you are using pods.Japanese
E
7

Product -> Clean then Product -> Run :)

Ethelred answered 5/6, 2016 at 8:35 Comment(0)
L
2

In my case, I mistakenly created a new subclass of UIView with .h and .c files instead of .h and .m files. Changing the extensions was easy, but I didn't think to change the contents of the .m files. So my .h files had

#ifndef My_Project_MPMyView_h
#define My_Project_MPMyView_h

#import <UIKit/UIKit.h>

@interface MPMyView : UIView

@end

#endif

and my .m files incorrectly had

#include <stdio.h>

When I changed my .m files to

@interface MPMyView : UIView

@end

@implementation MPMyView

@end

The linker error was fixed.

Luz answered 21/4, 2014 at 23:38 Comment(0)
T
0

I solved the same issue because I created components as separate projects. After adding the folders to the main project, I forgot to delete the .plist, .string and extra main.m files from the imported component group directories.

Deleting these solved my issue because the app was obviously getting conflicting build commands...

Thoroughwort answered 10/4, 2013 at 14:33 Comment(0)
B
0

I encountered this error due to duplicate filenames (I had created NSManagedObjectContext subclasses automatically in core data through the editor menu).

As of XCODE 5.0, just quit and restart and xcode should recognize this and fix it for you if you click on the yellow warning in the left hand pane

Brough answered 11/12, 2013 at 19:30 Comment(0)
P
0

A similar error just happened to me on Xcode 6.4. Seems like an Xcode bug.

My fix was to go to the ".o" file that caused the error, uncheck and recheck target memberships that you need.

Perished answered 15/7, 2015 at 15:12 Comment(0)
P
0

I think it might be that you are trying to create two different .C file (with main function) in one project. C only allows you to have one main entrance every project.

Pernod answered 18/12, 2016 at 12:50 Comment(0)
P
0

I don't know how it worked.But i simply closed the xcode and open again by clicking xcworkspace file and worked for me. you may try hopefully this can solve your problem thank you.

Portion answered 13/4, 2017 at 13:0 Comment(0)
C
0

Hold down alt . On the top toolbar go to

Product > clean build folder

Press "clean build folder" and wait for it to build and run. It should resolve any errors in the build file.

Conde answered 3/5, 2017 at 9:44 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.