duplicate symbols for architecture armv7

亡梦爱人 提交于 2019-11-27 06:48:24
Adrian Bigland

This can happen if you accidentally #import a .m file instead of the .h!

Vishal

Generally, this kind of error occurs due to duplicate classes and xibs in your project folder. For example, in my project I had some class files duplicated(.h/.m files). You can see these duplicate classes under target->Build phases->compile sources.

Just look and remove extra classes. Problem will be solved.

Happens with static variables in a header file (header file included in more than one implementations file).

I was getting this error because I used the Xcode recommended warning flags. GCC_NO_COMMON_BLOCKS = YES was causing the issue. Setting this back to NO fixed it for me.

This error can also be caused if you have cyclic imports.... lets suppose you have VC1.h, VC2.h, and VC3.h

examples that will cause the error: (all are the .h files)

  • If VC2 imports VC1 and VC1 imports VC2
  • If VC1 imports VC2 and VC2 imports VC3 and VC3 imports VC1

solution:

  • import inside the .m instead of the .h
  • if the .h needs that class use @class (nameOfClass); instead of importing the .h

Be careful when using #import, only import what you need.

Be careful if you're using Cordova iOS 4.5.0, an error of this kind may happen

duplicate symbol _OBJC_METACLASS_$_CDVLogger in:
   /Users/toto/Library/Developer/Xcode/DerivedData/imp-hkzujazvkracgugyxunzwnzpeiqx/Build/Intermediates/imp.build/Debug-iphoneos/imp.build/Objects-normal/armv7/CDVLogger.o
   /Users/toto/Library/Developer/Xcode/DerivedData/imp-hkzujazvkracgugyxunzwnzpeiqx/Build/Products/Debug-iphoneos/libCordova.a(CDVLogger.o)

ld: 2 duplicate symbols for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

It can be due to the use of cordova-plugin-console, which is not useful anymore in Cordova iOS 4.5.0 (and breaks the build too!).

To fix it

cordova plugin remove cordova-plugin-console

See reference : https://cordova.apache.org/announcements/2017/09/08/ios-release.html

I have faced this problem once before. The reason is that I copied some methods and variables declared in the implementation body from one class to another. So rename these methods and moved these variable to the interface declaration area => solved.

I was seeing the same issue, but with different libraries. The fix was the following:

Target -> Build Phases -> Linked Binary With Libraries

Make sure the libraries included make sense. In my case, my project had libPods*.a (I am using CocoaPods for dependency mgmt) but also a few libraries that were included in my pod shared libraries, and that was causing the duplicates.

I just fixed this error. I had CocoaPods installing a few frameworks (AWS, SDWebImage, AFNetworking. I manually dragged in 2 frameworks, Facebook and ImageIO. Most of my "duplicate symbol" errors were caught on Facebook classes. I deleted the framework and added it to the Podfile. Must have been an error or duplication in the libraries required by Facebook.

My problem was... odd. I'm not sure how it happened, but at some point, Xcode decided to include some ancient .m file one more time in its .pbxproj file. The only way I found it was by comparing my changes in git, looking at the version of the code where the build first failed.

Simply removing this line solved my issue:

I had duplicate files in my Xcode. Physically there were one m-file and one h-file. But in project it were doubled causing duplicates in compile sources. After deleting duplicate m and h file problem was solved.

Its because the iPhone simulator got duplicate .h & .m references. I struggled for hours for this bug.

My solution was simple. I copied the project to my pen drive and erased from computer memory.

Opened a new project, copied the storyboard and added the .h &.m files. Some errors fixed by selecting classes again in the storayboard view..

I also had duplicate symbols. I just renamed the procedure (app -> app1, app2) and the associated fields app.XXX -> app1.XXX . and it worked !

See : (in a .m file)

AppDelegate* app1;

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        app1 = (AppDelegate *)[[UIApplication sharedApplication] delegate];
    }
    return self;
}

(...)

- (int) getLimit
{
    if (app1.product2buyed)
        return MAXID;
    else if (app1.product1buyed)
        return 70;
    else
        return 10;

Please check if you have added any framework more then once, remove all framework if added multiple times and then drag and drop again.

Hope this will resolve your problem. Happy Coding.

YOU MIGHT HAVE SIMILAR PLUGINS INSTALLED.

I am using Cordova, and also had several duplicate symbol errors. I had installed two similar plugins:

  • cordova plugin email composer
  • cordova plugin email

Fixed it by removing "cordova plugin email" using...

cordova plugin remove cordova-plugin-email

After that I ran...

cordova prepare
cordova build ios

Now my xCode build ran like a charm! Woooo Hooo!

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