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

久未见 提交于 2020-01-10 07:49:06

问题


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)

回答1:


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.




回答2:


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




回答3:


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




回答4:


Product -> Clean then Product -> Run :)




回答5:


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.




回答6:


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




回答7:


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




回答8:


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.




回答9:


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.




回答10:


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.




回答11:


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.



来源:https://stackoverflow.com/questions/11553409/linker-command-error-ld-symbols-not-found-for-architecture-i386

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!