[ios] Duplicate symbols for architecture x86_64 under Xcode

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?

This question is related to ios objective-c xcode5

The answer is


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


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.


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.


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.


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


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

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


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.


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

It worked for me


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


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


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.


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.


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.


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

pod deintegrate
pod install

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


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";

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.


This answer explains well as to why this problem occurs:

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.


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


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.

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


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.


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


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!


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


Because I haven't seen this answer:

Uninstall and reinstall your podfiles! 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. :)


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

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.


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.


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


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

#import "ViewController.m"

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.


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.


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.


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.


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


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


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


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


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


In my case, there were two file by same name in the location

Targets > Build Phases > Compile Sources and delete any duplicate files.


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


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
    

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.


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.

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

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


Update answer for 2021, Xcode 12.X:

pod deintegrate 
pod install

Hope this helps!


Can you try clear all plugin under the plugin folder?

It is worked for me


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

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


Examples related to ios

Adding a UISegmentedControl to UITableView Crop image to specified size and picture location Undefined Symbols error when integrating Apptentive iOS SDK via Cocoapods Keep placeholder text in UITextField on input in IOS Accessing AppDelegate from framework? Autoresize View When SubViews are Added Warp \ bend effect on a UIView? Speech input for visually impaired users without the need to tap the screen make UITableViewCell selectable only while editing Xcode 12, building for iOS Simulator, but linking in object file built for iOS, for architecture arm64

Examples related to objective-c

Adding a UISegmentedControl to UITableView Keep placeholder text in UITextField on input in IOS Accessing AppDelegate from framework? Warp \ bend effect on a UIView? Use NSInteger as array index Detect if the device is iPhone X Linker Command failed with exit code 1 (use -v to see invocation), Xcode 8, Swift 3 ITSAppUsesNonExemptEncryption export compliance while internal testing? How to enable back/left swipe gesture in UINavigationController after setting leftBarButtonItem? Change status bar text color to light in iOS 9 with Objective-C

Examples related to xcode5

OS X Framework Library not loaded: 'Image not found' "The file "MyApp.app" couldn't be opened because you don't have permission to view it" when running app in Xcode 6 Beta 4 Duplicate symbols for architecture x86_64 under Xcode iOS 7 - Failing to instantiate default view controller Undefined symbols for architecture arm64 iOS 7 status bar overlapping UI Find provisioning profile in Xcode 5 iOS 7 App Icons, Launch images And Naming Convention While Keeping iOS 6 Icons Is it possible to install iOS 6 SDK on Xcode 5? Provisioning Profiles menu item missing from Xcode 5