Duplicate symbols for architecture x86_64 under Xcode

IosObjective CXcode5

Ios Problem Overview


I now have the same question with above title but have not found the right answer yet. I got the error:

    /Users/nle/Library/Developer/Xcode/DerivedData/TestMoboSDK-Client-cgodalyxmwqzynaxfbbewrooymnq/Build/Intermediates/TestMoboSDK-Client.build/Debug-iphonesimulator/TestMoboSDK-Client.build/Objects-normal/x86_64/MoboSDK.o
    /Users/nle/Library/Developer/Xcode/DerivedData/TestMoboSDK-Client-cgodalyxmwqzynaxfbbewrooymnq/Build/Products/Debug-iphonesimulator/libMoboSDK.a(MoboSDK.o)
duplicate symbol _OBJC_METACLASS_$_MoboSDK in:
    /Users/nle/Library/Developer/Xcode/DerivedData/TestMoboSDK-Client-cgodalyxmwqzynaxfbbewrooymnq/Build/Intermediates/TestMoboSDK-Client.build/Debug-iphonesimulator/TestMoboSDK-Client.build/Objects-normal/x86_64/MoboSDK.o
    /Users/nle/Library/Developer/Xcode/DerivedData/TestMoboSDK-Client-cgodalyxmwqzynaxfbbewrooymnq/Build/Products/Debug-iphonesimulator/libMoboSDK.a(MoboSDK.o)
ld: 75 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

Any help is appreciated.

Finally I find out the reason of this error cause I added -ObjC to the Other Linker Flags. After remove this value then I can build my project successfully, but I don't know why. Can anyone explain this?

Ios Solutions


Solution 1 - Ios

For me, changing 'No Common Blocks' from Yes to No ( under Targets->Build Settings->Apple LLVM - Code Generation ) fixed the problem.

Solution 2 - Ios

Stupid one, but make sure you haven't #imported a .m file by mistake somewhere

Solution 3 - Ios

> 75 duplicate symbols for architecture x86_64

Means that you have loaded same functions twice. As the issue disappear after removing -ObjC from Other Linker Flags, this means that this option result that functions loads twice:

from Technical Q&A

> This flag causes the linker to load every object file in the library > that defines an Objective-C class or category. While this option will > typically result in a larger executable (due to additional object code > loaded into the application), it will allow the successful creation of > effective Objective-C static libraries that contain categories on > existing classes.

https://developer.apple.com/library/content/qa/qa1490/_index.html

Solution 4 - Ios

In my case, I just created a header file to define constant strings like this:

NSString *const AppDescriptionString = @"Healthy is the best way to keep fit";

I solved this scenario by using static:

static NSString *const AppDescriptionString = @"Healthy is the best way to keep fit";

Solution 5 - Ios

Happens also when you declare const variables with same name in different class:

in file Message.m

const int kMessageLength = 36;

@implementation Message

@end

in file Chat.m

const int kMessageLength = 20;

@implementation Chat

@end

Solution 6 - Ios

I have same problem. In Xcode 7.2 in path Project Target > Build Setting > No Common Blocks, i change it to NO.

Solution 7 - Ios

I found the accepted answer touches on the problem but didn't help me solve it, hopefully this answer will help with this very frustrating issue.

duplicate symbol _OBJC_IVAR_$_BLoginViewController._hud in:

17 duplicate symbols for architecture x86_64

"Means that you have loaded same functions twice. As the issue disappear after removing -ObjC from Other Linker Flags, this means that this option result that functions loads twice:"

In layman's terms this means we have two files in our project with exactly the same name. Maybe you are combining one project into another one? Have a look at the errors above the "duplicate symbols" error to see which folder is duplicated, in my case it was BLoginViewController.

For example, in the image below you can see I have two BImageViewControllers, for me this is what was causing the issue.

As soon as I deleted one then the issue vanished :)

enter image description here

Solution 8 - Ios

This occurred on me when I accepted "recommended settings" pop-up on a project that I develop two years ago in Objective-C.

The problem was that when you accepted the "recommended settings" update, Xcode automatically changed or added some build settings, including GCC_NO_COMMON_BLOCKS = YES;.

This made the build failed with the duplicate symbol error in my updated project. So I changed No Common Block to NO in my build settings and the error was gone.

Solution 9 - Ios

I experienced this issue after installing Cocoapods. Now happens everytime I update some pods. Solution I've found:

Go to terminal:

1) pod deintegrate
2) pod install

Also, check the item "Always Embed Swift Libraries" in your Build Settings. It should be "faded" indicating it is using the default configuration. If its set to a manual YES, hit delete over it to revert it to the default configuration. This stopped the behavior.

Solution 10 - Ios

Fastest way to find the duplicate is:

  1. Go to Targets
  2. Go to Build Phases
  3. Go to Compile Sources
  4. Delete duplicate files.

Solution 11 - Ios

  • Go to Targets
  • Select Build Settings
  • Search for "No Common Blocks", select it to NO.

It worked for me

Solution 12 - Ios

Following steps solved the issue for me.

  1. Go to Build Phases in Target settings.

  2. Go to “Link Binary With Libraries”.

  3. Check if any of the libraries exist twice.

  4. Build again.

Solution 13 - Ios

Remove -ObjC from Other Linker Flags or Please check you imported any .m file instead of .h by mistake.

Solution 14 - Ios

My situation with some legacy project opened in Xcode 7.3 was:

duplicate symbol _SomeEnumState in:

followed with list of two unrelated files.o, then this was repeated couple of times, then finally:

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

What solved it for me was changing enum declaration from:

enum SomeEnumState {
    SomeEnumStateActive = 0,
    SomeEnumStateUsed = 1,
    SomeEnumStateHidden = 2
} SomeEnumState;

to this:

typedef NS_ENUM(NSUInteger, SomeEnumState) {
    SomeEnumStateActive = 0,
    SomeEnumStateUsed = 1,
    SomeEnumStateHidden = 2
};

If somebody has explanation for this, please enlighten me.

Solution 15 - Ios

Update answer for 2021, Xcode 12.X:

pod deintegrate 
pod install

Hope this helps!

Solution 16 - Ios

Defining same variable under @implementation in more than one class also can cause this problem.

Solution 17 - Ios

In my case, there were two file by same name in the location > Targets > Build Phases > Compile Sources and delete any duplicate files.

Solution 18 - Ios

For me during the Xcode8 recommended project settings update "No Common Blocks" to YES which causes this issue.

Solution 19 - Ios

Today , I got the same error . The error's key word is duplicate. I fix it by:

1. Remove the duplicate file at Build Phases-->Compile Sources
2. If you can not remove it at Build Phases, you need find the file at your project and remove the reference by DELETE :

remove reference

3. Add the file to your project again
4. Add the file's .m to your Build Phases-->Compile Sources again
5. Build your project, the error will disappear

Solution 20 - Ios

I got the same error when I added a pod repository

pod 'SWRevealViewController'

for an already added source code (SWRevealViewController) from gitHub. So, the error will be fixed by either removing the source code or pod repository.

Case # 2:

The 2nd time, this error appeared when I declare a constant in .h file.

NSString * const SomeConstant  = @"SomeValue";
@interface AppDelegate : UIResponder <UIApplicationDelegate> {
...
...

Solution 21 - Ios

Another silly mistake that will cause this error is repeated files. I accidentally copied some files twice. First I went to Targets -> Build Phases -> Compile sources. There I noticed some files on that list twice and their locations.

Solution 22 - Ios

Make sure you haven't imported a .m file by accident, you might want to delete your derived data in the Projects Window and then build and run again.

Solution 23 - Ios

For anyone else who is having this issue, I didn't see my resolution in any of these answers.

After having a .pbxproj merge conflict which was manually addressed (albeit poorly), there were duplicate references to individual class files in the .pbxproj. Deleting those from the Project > Build Phases > Compile Sources fixed everything for me.

Hope this helps someone down the line.

Solution 24 - Ios

Similar to Juice007, I had declared and initialized a C type variable in two different .m files (that weren't imported!)

BOOL myVar = NO;

however, this method of declaring and initializing a variable, even in .m, even in @implementation grants it global scope. Your options are:

  1. Declare it as static, to limit the scope to class:

    static BOOL myVar = NO;
    
  2. Remove the initialization (which will make the two classes share the global var):

    BOOL myVar;
    -(void) init{
        myVar = NO;
    }
    
  3. Declare it as a property:

    @property BOOL myVar;
    
  4. Declare it as a proper iVar in the @interface

    @interface myClass(){
        BOOL myVar;
    }
    @end
    

Solution 25 - Ios

In my case I had two main() methods defined in my project and removing one solved the issue.

Solution 26 - Ios

The answers above didn't work for me. Here's how I got around it:

  1. in finder, delete the entire Pods folder and Podfile.lock file
  2. close the xcode project
  3. run pod install in the terminal
  4. open the xcode project, run the clean build command

Worked for me after that.

Solution 27 - Ios

Because I haven't seen this answer:

Uninstall and reinstall your podfiles! https://stackoverflow.com/questions/13751147/remove-or-uninstall-library-previously-added-cocoapods

I've run into this issue over 3 times building my app and every time this is what fixes it. :)

Solution 28 - Ios

Same issue happen with me, when I was integrating the lob project inside my project.

enter image description here

Actually lob project also have the AFNetworking files, So I remove the .m files from lob project.

enter image description here

Actually .m files are conflicting with My project POd/AFNetworking/ .m files

enter image description here

Solution 29 - Ios

Recently had a headache looking for source of an error. I was wondered, when i found out that my app doesn't want to compile, simply because i had following code snippet in different classes:

dispatch_time_t getDispatchTimeByDate(NSDate *date)
{
    NSTimeInterval interval;
    double second, subsecond;
    struct timespec time;
    dispatch_time_t milestone;
    
    
    interval = [date timeIntervalSince1970];
    subsecond = modf(interval, &second);
    time.tv_sec = second;
    time.tv_nsec = subsecond * NSEC_PER_SEC;
    milestone = dispatch_walltime(&time, 0);
    
    return milestone;
}

Hope that might help someone.

Solution 30 - Ios

I hope it will definitely help you

I got same error 3 duplicate symbols for architecture x86_64

in my case I have copied code from another file of same project eg. code of A.m file to B.m and after complilation i got an error as mention. and i have solve error by changing the name of global Variable.

this error came in my case because of same declare for global variable in both file.

Solution 31 - Ios

None of above solutions works for me, I just fixed it myself.

I got duplicate symbol of my core data model which I make it myself, but in my .xcdatamodeld inspector, I choose Class Definition of Codegen property, I guess that's what's wrong with. Then I choose Manual/None,it got fixed.

Hope this can be helpful for you!

Solution 32 - Ios

Sometimes, this happens when you have the wrong file in import like for ex.:

> import "MenuItem.m"

Instead of

> import "MenuItem.h"

this will throw that duplicate error duplicate symbols for architecture x86_64

Solution 33 - Ios

I've just had this error as well. Found that the problem was variables declared with global scope, with the same names, were being repeated throughout the files being compiled into the program. Once changing the global variables to local scope to the pseudo-main function the error was resolved.

Solution 34 - Ios

My problem was that I had 5 duplicate symbols for architecture x86_64. After reading this post and their answers, I try with the common solution about change GCC_NO_COMMON_BLOCKS = YES to NO

But, instead of working for me, I went from 5 duplicates to 1 duplicate...

So, I paid attention to that last error, and I realized what was my problem, and it was an "incompatibility" with these packages (I had both in package.json):

rn-fetch-blob
react-native-blob-util

The message was clear about it, and I remove rn-fetch-blob because I have not idea why it was in my project, but, I only used with jest and delete it, it wasn't a problem.

So, after removing that package, and run yarn again, problem solved... And without changing the GCC_NO_COMMON_BLOCKS

Solution 35 - Ios

In Xcode 6.3.2. I have checked all possibility like as belowed

1: I have not import .m file in my project.

2: Removed -ObjC from Other linker flag.

3: Removed all my derive Data.

still i am getting same error. I have removed this error by removing any variable declaration from .pch file. in my case, i have declared AppDelegate object in .pch file. finally i found reason that cause error. so i remove declaration of any variable from .pch file and my project working charm.

Solution 36 - Ios

I also have this fault today.That's because I defined a const value in a .m file.But I defined another .m file that also included this const value.That's means it has two same const values.So this error appears. And my solution is adding a keyword "static" before the const value.such as:

static CGFloat const btnConunt = 9;

And then I build the project it won't report this error.

Solution 37 - Ios

1.Go to Build Phases

2.Search for the file name

3.Delete duplicate

-> Error will go away.

If it doesn't, try to search for "file.m", if you see any #import "file.m" , clear this line

Solution 38 - Ios

I face the same error what i did

1.Copy the duplicate symbol file (class name or framework name) from the end which is just showed above of the line (duplicate symbols for architecture x86_64).

2. Paste it in Find Navigator and press enter

It showed me duplicate class. I remove the duplicate class and run successfully.

Solution 39 - Ios

This error generally occurs when you have linked any library or file twice. In the error desciption, the name of the duplicated file will be listed, you can search and and make sure you don't have duplicates. If you find duplicates, remove reference to one of them to play safe

Solution 40 - Ios

Ensure you are not importing [ViewController.m] instead of header file

#import "ViewController.m"

Solution 41 - Ios

This answer explains well as to why this problem occurs:

https://stackoverflow.com/questions/27436981/xcode-c-duplicate-symbols-for-architecture-x86-64

In my opinion you do not need to turn any of the flags off or change Xcode settings, re-read your code, and fix the problem. Changing the settings would just subside the inflammation not the cause.

Solution 42 - Ios

Remove -all_load from Other Linker Flags. It works on my project

Solution 43 - Ios

If you're using and think it might be your pods, try this:

pod deintegrate
pod install

Solution 44 - Ios

I just encoutered the problem. The pod deintegrate or Removing podfile.lock ways would be helpful for you, but try the following sequence , that may be more helpful than deintegrating the pod files

  • Comment all the pods in Podfile

  • run the pod install, it will remove Pods folder from the project

  • Uncomment all the pods in Podfile

  • run again pod install

Solution 45 - Ios

If you have some common functions defined in a header file, change them into inline.

Solution 46 - Ios

My mistake was having implemented functions in header files. There should be a clear separation between function definitions in header files, and function implementations in the code files.

For example, I had something like:

my_header.h

#ifdef my_header_h
#define my_header_h

int foo() { return 123; }

#endif // my_header_h

which should be:

#ifdef my_header_h
#define my_header_h

int foo();

#endif // my_header_h

Solution 47 - Ios

This Answer works with Xcode 12.5.1, worked for me on 2021

  1. Close your Xcode project.
  2. Go to your project directory, if you use flutter don't forget to get in "ios" file in the project folder.
  3. Delete [Pods, Podfile, Podfile.lock].
  4. Run the terminal.
  5. Go to your project directory.

If you use swift you're done here jump to xcode and run the app or keep on if you're using flutter

  1. Run flutter clean.
  2. Run flutter pub get.
  3. Run flutter run. Don't forget to run the simulator before you use flutter run command.

Congrats everything should work!

Solution 48 - Ios

For the case of React Native, the solution was simply deleting all of the libraries in: Target > Build Phases > Link Binary with Library.

Link Binary with Library

I don't really know the cause, but I assume React Native already has the packages installed, creating duplicates.

Solution 49 - Ios

For me, this happened when mistakenly I defined two entry points for my APP

@main struct AppName: App { //Comment - @main

Or

@UIApplicationMain class AppDelegate //Comment - @UIApplicationMain

Solution 50 - Ios

This error happened to me when I implemented a class method with a scope resolution operator in the header file, instead of .cpp file.

PS: And I was programming in C++ on Macbook Yosemite.

Solution 51 - Ios

In my case, I named an Entity of my Core Data Model the same as an Object. So: I defined an object "Event.h" and at the same time I had this entity called "Event". I ended up renaming the entity.

Solution 52 - Ios

Can you try clear all plugin under the plugin folder?

It is worked for me

Solution 53 - Ios

Please check with the pod and Libraries you added. There should be one or more libraries are repeated. Please remove it from one side. I will fix the issue. And the effected library will listed in x-code error message detail.

Solution 54 - Ios

just uninstall the pod which it is related to and reinstall them.

Solution 55 - Ios

None of the above mentioned answer helped, as i had similar errors in pods and locally stored framework that looked like this,

duplicate symbol '_OBJC_METACLASS_$_EZAudioDevice' in:
    /Users/(yourUserName)/Desktop/Source Code/(yourProjectName)/Pods/AudioKit/iOS/AudioKit.framework/AudioKit(EZAudioDevice.o)
    /Users/(yourUserName)/Desktop/Source Code/(yourProjectName)/ChirpSDK.framework/ChirpSDK(EZAudioDevice.o)

So the fix was to locate /Users/(yourUserName)/Desktop/Source Code/(yourProjectName)/Pods directory in project where you will find these two files namely,

  • Pods-(yourProjectName).debug.xcconfig
  • Pods-(yourProjectName).release.xcconfig

In both of these files, you need to remove -ObjC flag under OTHER_LDFLAGS = $(inherited), the rational for removing this is as same as already mention here

Solution 56 - Ios

I simply just unistalled all my pods and reinstalled them. I also got rid of some pods i did not use.

Solution 57 - Ios

Open your project in XCode

you will see the sidebar now focus on the attached image.enter image description here

Search your specific SDK or any dublicate file where you facing an issue.

You will see that you have added any file twice.

just remove that file and your issue will be resolved.

Note: you have to remove the file from that place where you add it wrongly.

FOR EXAMPLE enter image description here

Note: Just remove FBSDKCoreKit from Frameworks

Good Luck

Solution 58 - Ios

I tried following this steps and It works for me now.

  1. Open Xcode > Pods > Targets Support Files > Pods-{TARGET-NAME}

    find "OTHER_LDFLAGS" and remove only "-ObjC" in these two files:

    Pods-{TARGET-NAME}.release.xcconfig & Pods-{TARGET-NAME}.debug.xcconfig

  2. Go to project main target > Build Settings > Other Linker Flags:

    Make sure no "-ObjC" is left in the value

  3. I deleted the build/Build folder in ios and run-ios again. It works now.

Solution 59 - Ios

Ive got this error after installed alamofires pod, but alamafire was already installed as package through xcode`s File/Add Packages.... error gone after I removed the package and also removed it from Targets/General/Frameworks...

Solution 60 - Ios

I am also faced this issue on FBReactNativeSpec, just made check on Run script - For install builds only

enter image description here

Solution 61 - Ios

In my case, i changed the Build System to Legacy and it worked.

You can access this option in the menu:

File > Workspace Settings > Build System

enter image description here

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
QuestionleeView Question on Stackoverflow
Solution 1 - IosLinda MacPhee-CobbView Answer on Stackoverflow
Solution 2 - IosAdam WaiteView Answer on Stackoverflow
Solution 3 - IosDavid VView Answer on Stackoverflow
Solution 4 - IosSauvik DoluiView Answer on Stackoverflow
Solution 5 - IosLuca DavanzoView Answer on Stackoverflow
Solution 6 - IosDr. chamranView Answer on Stackoverflow
Solution 7 - Iossam_smithView Answer on Stackoverflow
Solution 8 - IosBlaszardView Answer on Stackoverflow
Solution 9 - IosTDesignView Answer on Stackoverflow
Solution 10 - IosJ. GoceView Answer on Stackoverflow
Solution 11 - IosDeepak SasindranView Answer on Stackoverflow
Solution 12 - IospigeonView Answer on Stackoverflow
Solution 13 - IosCKR666View Answer on Stackoverflow
Solution 14 - IostadijaView Answer on Stackoverflow
Solution 15 - IosT D NguyenView Answer on Stackoverflow
Solution 16 - IosShreeView Answer on Stackoverflow
Solution 17 - IosNijView Answer on Stackoverflow
Solution 18 - IosNaveen ShanView Answer on Stackoverflow
Solution 19 - IosguozqzzuView Answer on Stackoverflow
Solution 20 - IoszeeawanView Answer on Stackoverflow
Solution 21 - IosAndrew McKinleyView Answer on Stackoverflow
Solution 22 - IosJohnVanDijkView Answer on Stackoverflow
Solution 23 - IosspentagView Answer on Stackoverflow
Solution 24 - IosMarsView Answer on Stackoverflow
Solution 25 - IosPradeep Kumar KushwahaView Answer on Stackoverflow
Solution 26 - IosFaye HayesView Answer on Stackoverflow
Solution 27 - IosKaseyView Answer on Stackoverflow
Solution 28 - Iosabdulrauf618View Answer on Stackoverflow
Solution 29 - IosEvgeniy KlebanView Answer on Stackoverflow
Solution 30 - IosBhupendrasingh LoharView Answer on Stackoverflow
Solution 31 - IosfoolishBoyView Answer on Stackoverflow
Solution 32 - IosNFerociousView Answer on Stackoverflow
Solution 33 - IosMatt CView Answer on Stackoverflow
Solution 34 - IosKalamaricoView Answer on Stackoverflow
Solution 35 - IosJatin Patel - JPView Answer on Stackoverflow
Solution 36 - IosJuice007View Answer on Stackoverflow
Solution 37 - IosjonypzView Answer on Stackoverflow
Solution 38 - IosGurjinder SinghView Answer on Stackoverflow
Solution 39 - IosArthiView Answer on Stackoverflow
Solution 40 - IosWonderXView Answer on Stackoverflow
Solution 41 - IosMudit VermaView Answer on Stackoverflow
Solution 42 - IoscodamanView Answer on Stackoverflow
Solution 43 - Iosuser4414149View Answer on Stackoverflow
Solution 44 - IosAnkur LahiryView Answer on Stackoverflow
Solution 45 - IosOne Eyed RavenView Answer on Stackoverflow
Solution 46 - IosPnemonicView Answer on Stackoverflow
Solution 47 - Ios3BadyView Answer on Stackoverflow
Solution 48 - IosMIPBView Answer on Stackoverflow
Solution 49 - IosPramodView Answer on Stackoverflow
Solution 50 - IoseneskiView Answer on Stackoverflow
Solution 51 - IosSjakelienView Answer on Stackoverflow
Solution 52 - IosFerhat KOÇERView Answer on Stackoverflow
Solution 53 - IosJebin BennyView Answer on Stackoverflow
Solution 54 - IosRajat ChaudharyView Answer on Stackoverflow
Solution 55 - IosFrostmourneView Answer on Stackoverflow
Solution 56 - IosAsbisView Answer on Stackoverflow
Solution 57 - IosRasheed QureshiView Answer on Stackoverflow
Solution 58 - IosVikram ChaudharyView Answer on Stackoverflow
Solution 59 - IosYevgen SomochkinView Answer on Stackoverflow
Solution 60 - Ioskarthik manoView Answer on Stackoverflow
Solution 61 - IosAnderson BressaneView Answer on Stackoverflow