303

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?

jww
  • 97,681
  • 90
  • 411
  • 885
lee
  • 7,955
  • 8
  • 44
  • 60
  • The linker has encountered symbols defined more than once - 75, to be exact. This is likely because you `#include`'d or `#import`'d something (likely the MoboSDK, whatever that is) more than once. – ravron Jun 19 '14 at 04:30
  • this error happen after I add `GoogleConversionTrackingSDK-iOS-3.0` into my project.Before that, it's work ok.I also tried to remove it, but the error still happen. – lee Jun 19 '14 at 04:38
  • it's not your case, cause before I add the sdk of google my project build ok. – lee Jun 19 '14 at 04:40
  • Second answer from Adam Waite is really straight forward. Make sure there is no .m file #imported somewhere. – Bogdan Mar 22 '16 at 08:27
  • In my case I was trying to use same string array name in two separate classes. When I have changed the array name in one of the classes this error has been removed. – Hope Sep 15 '16 at 08:20
  • Make sure you #include a .h file, not a .m. – doxsi Feb 01 '17 at 15:43
  • try this : http://stackoverflow.com/a/42089897/3024579 – Alok Feb 07 '17 at 12:42
  • A very similar error is thrown by accidentally including a `.cpp` file instead of it's corresponding header file `.hpp`! – David Ferris Jan 03 '18 at 23:26
  • I have tried most of the suggested solutions below but I still have the error, can anyone please help. 1. I didn't find any duplicate files at Targets > Build Phases > Compile Sources 2. I changed the No Common Data to No, not working 3. I deleted all the derived data, clean and rebuild, Failed. https://stackoverflow.com/questions/49669403/1-duplicate-symbol-for-architecture-x86-64?noredirect=1#comment86478950_49669403 – Hanz Cheah Apr 10 '18 at 02:40
  • Worked perfect for me! – yuchen Mar 07 '22 at 06:14

66 Answers66

291

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

Linda MacPhee-Cobb
  • 7,646
  • 3
  • 20
  • 18
  • 5
    This solved my problem. Is it ever require to change it back to `NO` ? What's the reason behind this ? – Hemang Aug 20 '15 at 09:11
  • If I were writing functional code in Swift I wouldn't want any common blocks of code, but writing OOP/MVC code in ObjC sometimes it makes sense to have duplicated blocks ( I have both metric and imperial functions that calculate similar things in many of my fitness apps ) – Linda MacPhee-Cobb Aug 24 '15 at 22:27
  • 4
    Yes this solves the problem, but not the reason behind it. If you defined a const, make sure that definiton is ok. In my case I simply forgot "extern". This is mentioned in Sauvik Dolui answer. – coco Mar 14 '16 at 08:48
  • 10
    Xcode 8 prompted this change as one of its automatic updates and broke my build :/ – pkamb Oct 07 '16 at 16:18
  • Xcode 9 automatically changed it in automatic update of an old project. Restored to "NO" and build succeeded. – Axeman Nov 16 '17 at 09:09
  • 2
    This works, but I had to change it in target and project – Nooblhu Apr 04 '18 at 08:30
  • What does it do? – I make my mark Jul 18 '19 at 19:33
  • 1
    In xcode 10 it's now under Apple Clang - Code Generation Thanks ! – foufrix Feb 10 '20 at 11:57
269

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

Adam Waite
  • 19,175
  • 22
  • 126
  • 148
  • 3
    I hadn't done this, but this solution helped me find what I had done which was to declare a variable outside the @interface block in a .h file by mistake. – Scooter Nov 24 '16 at 21:21
  • When using unit tests, only the .m file is generated. I created a header file for it despite i guess this is not the best solution - i wanted to create a base test class. – Bruno Muniz Aug 23 '17 at 10:13
  • Thank you so much for enlightening my mind for the possibility that I made such a stupid mistake. – Daniel Lima Oct 02 '17 at 05:32
  • how about cross-project import .m file? – noveleven Feb 22 '19 at 08:36
  • Just need to import `.h` file – Farras Doko Feb 06 '21 at 08:07
  • I tried switching the build setting flag, didn't work. I tried creating a new header file, importing the .h instead of .m, and placing the contents of my .m file inside the header file and it worked. – Tim Sonner Jun 26 '22 at 17:43
130

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

Cœur
  • 37,241
  • 25
  • 195
  • 267
David V
  • 2,134
  • 1
  • 16
  • 22
  • 2
    In other words, make sure you remove any object files in your xcode project. – Reuben Tanner Nov 01 '14 at 19:55
  • 10
    It also work for me too, but my other libraries are depends on `-ObjC` flag. So I must need to keep this flag in my project settings. So could you please suggest any other solution? – Sunil Targe Aug 24 '16 at 08:20
  • 4
    I guess you need to review all your libraries: If you get duplicate linker error, that means you have same source code in 2 or more libraries. – David V Aug 24 '16 at 10:15
  • I had to remove some of the React libraries it was complaining about under Target->Build Phases->Link Binary With Libraries in Xcode since it was conflicting with my cocoa pods install of React – Coty Embry Apr 30 '17 at 01:14
  • In my case I have import .m file. So stupid mistake. Once I imported .h file. It is ready for build!! Thanks – Ravi Dec 07 '17 at 07:35
63

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";
Ky -
  • 30,724
  • 51
  • 192
  • 308
Sauvik Dolui
  • 5,520
  • 3
  • 34
  • 44
  • 3
    this solved the issue for me. Although i prefixed `extern` instead of `static` : `extern NSString * const kNotificationName;`. Which is strange, because u usually did not add such prefix, and it worked fine.. – user1244109 Jul 25 '15 at 09:38
  • This, for some reason, solved my issue. Thanks. I don't understand why the compiler couldn't give out a better response than duplicate symbols, which doesn't seem related at all. – Allison Oct 14 '15 at 20:39
  • @Sirens, I also expected a better error message from the LLVM compiler. Anyway I was lucky enough to find out the error after 2 days. :( – Sauvik Dolui Oct 15 '15 at 07:09
  • this was my problem as well why is the actual problem caused by this? – Fatlad Nov 11 '15 at 23:52
  • This is fine if all the variables in `AppStrings.h` are constants, however it will cause havok if you want a global mutable variable as every source file that includes the header file will have their own copy of the variable. It's a bad solution. – trojanfoe Mar 30 '16 at 09:43
  • @user1244109 `static` is for when you actually have a value (`static NSString * kFoo = @"Foo";`) and `extern` is for when you are just saying "this constant exists but its value is defined in the `.m`/`.c`/etc. (`extern NSString * kFoo;`). Also, I recommend using `FOUNDATION_EXPORT` because it adapts to different compilation environments (ObjC, ObjC++, Win32, etc.) – Ky - Aug 30 '17 at 14:26
36

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
Luca Davanzo
  • 21,000
  • 15
  • 120
  • 146
  • 2
    Not const but it worked for me when I change variable name – Oktay Mar 14 '16 at 20:51
  • I had this with a pointer of my own class variable defined in the @implementation of two different classes – ammianus Oct 07 '17 at 21:32
  • At compile time, compiler checks for duplicate symbols (here global variables) only in header(.h) files. But at linking time the (global) variables in implementation(.m) files are also checked and if there any duplicate, Linker will through error : duplicate symbol _xyz – PANKAJ VERMA Dec 29 '17 at 06:58
  • I had to rename even local variables @implementation DIOOutstreamVideoView CGFloat visibleHeightOut; CGFloat fullHeightOut; – Bitlejuce Do Apr 30 '21 at 08:00
36

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

Dr. chamran
  • 540
  • 4
  • 11
34

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

sam_smith
  • 6,023
  • 3
  • 43
  • 60
  • 2
    Huge help, thank you. I have taken a backup of a project that uses cocoapods. In forgetting I needed to open the workspace when I reloaded the backup in Xcode and found it wouldn't build, I then added AFNetworking directly to the project. I subsequently went on to re-setup my cocoapods, which included AFNetworking as a dependency and forgot to remove the original AFNetworking folder that I had added to my project. – JanB Feb 16 '15 at 13:51
33

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.

Blaszard
  • 30,954
  • 51
  • 153
  • 233
24

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.

TDesign
  • 569
  • 4
  • 8
  • This worked for me. However, "Always Embed Swift Libraries" was already set to NO. I switched it to YES and then hit delete and then ran the pod functions stated above. – BVB09 May 24 '20 at 11:36
20

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.
NSNoob
  • 5,548
  • 6
  • 41
  • 54
J. Goce
  • 279
  • 3
  • 10
  • Add a couple more hours to that. – CJ_COIMBRA Dec 24 '19 at 16:00
  • which is only for class files like .h, .m or .swift files. Not for frame work level files. – Naresh Sep 22 '20 at 13:04
  • This was the easiest way. Thanks! I was having that problem with a c code and I follow this steps and it work. Although I have to clarify that don't delete the file with your main function because it won't work. – Josue Gisber Apr 05 '22 at 00:07
  • Thanks! man. Atlast for your answer I'm able to run the app for first time... Thank you very much!!! – Anirban Das Jun 26 '22 at 20:41
18
  • Go to Targets
  • Select Build Settings
  • Search for "No Common Blocks", select it to NO.

It worked for me

Hemant Singh Rathore
  • 2,153
  • 1
  • 24
  • 38
Deepak Sasindran
  • 494
  • 1
  • 6
  • 13
15

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.
pigeon
  • 151
  • 1
  • 2
13

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

CKR666
  • 1,497
  • 1
  • 13
  • 10
  • 2
    Hey, everybody, who is still wondering why -ObjC flag doesn't work - pay attention to this answer. I was completely wrong thinking -ObjC flag doesn't work in my "super special" case. After searching through the project for smth like `.m"` I have noticed that I did import .m file instead of .h and after fixing that it just worked! `Talk is cheap, show me the code!` Cheers! – bgplaya Oct 06 '15 at 13:50
11

Update answer for 2021, Xcode 12.X:

pod deintegrate 
pod install

Hope this helps!

T D Nguyen
  • 7,054
  • 4
  • 51
  • 71
10

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.

tadija
  • 2,981
  • 26
  • 37
  • Same thing fixed it for me, when I switched enum to typedef NS_ENUM it fixed the duplicate symbols error – Mark24x7 Oct 05 '16 at 17:37
9

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

Shree
  • 281
  • 3
  • 9
9

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

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

Neeraj Joshi
  • 721
  • 9
  • 26
8

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

Kalamarico
  • 5,466
  • 22
  • 53
  • 70
  • 2
    Thank you, it didn't solve my problem but decreased the duplications from 14 to 9 – Jafar Jabr Mar 16 '22 at 16:12
  • 1
    the rest solved by removing "use_flipper!()" from podFile – Jafar Jabr Mar 16 '22 at 16:59
  • I'm glad to hear that!! And thanks for your input! – Kalamarico Mar 17 '22 at 17:15
  • 1
    rn-fetch-blob is deprecated at this point and react-native-blob-util is a fork from it. If you use both you get this issue. I had the same problem. In the end, I had to manually link the library for some other compatibility problem but the issue was gone. – sebastianf182 Jun 28 '22 at 10:57
7

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

Naveen Shan
  • 9,192
  • 3
  • 29
  • 43
5

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
guozqzzu
  • 839
  • 10
  • 12
  • Thanks! In my case I compiled two main.m where one was the old reference. This was caused by drag and drop. – tong Jun 14 '20 at 11:08
4

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> {
...
...
zeeawan
  • 6,667
  • 2
  • 50
  • 56
4

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.

Andrew McKinley
  • 1,137
  • 1
  • 6
  • 11
4

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.

JohnVanDijk
  • 3,546
  • 1
  • 24
  • 27
4

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!

Charuක
  • 12,953
  • 5
  • 50
  • 88
foolishBoy
  • 331
  • 1
  • 12
  • This will help anyone who adds tables periodically to their .xcdatamodel, I'm bookmarking this response since I do this only often enough to completely forget how to fix the problem when it happens again. – Sashah Sep 26 '22 at 13:58
4

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.

spentag
  • 147
  • 9
  • 1
    also had merging conflicts and had to manually resolve them in pbxproj file. Ended up with `ld: X duplicate symbols for architecture x86_64`. Fixed it by removing the source files mentioned in error message and re-adding them again to the project. – kas-kad Dec 05 '17 at 10:39
4

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
    
Mars
  • 2,505
  • 17
  • 26
4

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

Pradeep Kumar Kushwaha
  • 2,231
  • 3
  • 23
  • 34
4

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.

Faye Hayes
  • 263
  • 3
  • 13
4

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

Kasey
  • 374
  • 2
  • 12
  • 2
    I've also been running into this a lot more lately. Not sure if it has something to do with Xcode 11 or Catalina but this is what usually fixes my project as well. 1. Open your Podfile 2. Comment out `ALL` your pods 3. Run `pod install` 4. Uncomment your pods in the Podfile 5. Run `pod install` again 6. Profit – Kilo Loco Feb 04 '20 at 14:12
  • @kiloLoco Yeah I think it's a bug in Xcode? Maybe I'm wrong. – Kasey Feb 04 '20 at 16:46
4

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.

Matt C
  • 63
  • 5
3

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

abdulrauf618
  • 341
  • 1
  • 10
3

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.

Evgeniy Kleban
  • 6,794
  • 13
  • 54
  • 107
3

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.

3

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

eNeF
  • 3,241
  • 2
  • 18
  • 41
3

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

Pramod
  • 1,123
  • 2
  • 12
  • 33
  • That was it for me. I copied and pasted one app into another, and forgot the pasted SwiftUI app had its own @main entry. Therefore 2 entry points to my app. – Just a coder Apr 20 '22 at 17:46
  • This is what helped me! I was adding SwiftUI to my existing project and adding @main to my SwiftUI class. – waseefakhtar Aug 08 '23 at 10:40
3

If you're coming here for a React Native Project, then go to the following,

Targets -> <Your-App> -> Build Settings -> Dead Code Stripping

Change from No to Yes for Debug.

P.S. This approach works for React Native projects, not sure if it will work for a native project too.

gprathour
  • 14,813
  • 5
  • 66
  • 90
2

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.

Jatin Patel - JP
  • 3,725
  • 2
  • 21
  • 43
2

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.

Juice007
  • 1,054
  • 1
  • 9
  • 14
2

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

Naresh
  • 16,698
  • 6
  • 112
  • 113
jonypz
  • 1,515
  • 1
  • 20
  • 35
2

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.

Gurjinder Singh
  • 9,221
  • 1
  • 66
  • 58
2

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

Arthi
  • 128
  • 1
  • 7
2

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

#import "ViewController.m"
WonderX
  • 95
  • 9
2

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.

pkamb
  • 33,281
  • 23
  • 160
  • 191
Mudit Verma
  • 374
  • 2
  • 6
2

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

codaman
  • 206
  • 4
  • 6
  • This got rid of the error for me but now got `determineAppInstallationAttributionWithCompletionHandler:, lookupAdConversionDetails:, transform:`, maybe unrelated – Mike Flynn Oct 04 '22 at 01:42
2

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

pod deintegrate
pod install
1

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
Ankur Lahiry
  • 2,253
  • 1
  • 15
  • 25
1

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

Dovahkiin
  • 1,239
  • 11
  • 23
1

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
Pnemonic
  • 1,685
  • 17
  • 17
1

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!

3Bady
  • 183
  • 3
  • 15
1

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.

MIPB
  • 1,770
  • 2
  • 12
  • 21
0

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.

eneski
  • 1,575
  • 17
  • 40
0

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.

Sjakelien
  • 2,255
  • 3
  • 25
  • 43
0

Can you try clear all plugin under the plugin folder?

It is worked for me

Ferhat KOÇER
  • 3,890
  • 1
  • 26
  • 26
0

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.

Jebin Benny
  • 933
  • 1
  • 5
  • 9
0

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

0

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

Frostmourne
  • 156
  • 1
  • 19
0

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

Asbis
  • 432
  • 5
  • 16
0

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

Rasheed Qureshi
  • 1,215
  • 1
  • 11
  • 19
0

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.

matt
  • 515,959
  • 87
  • 875
  • 1,141
Vikram Chaudhary
  • 580
  • 4
  • 14
0

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

0

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

enter image description here

karthik mano
  • 111
  • 1
  • 5
0

I got the same issue in Xcode 14. Cleaning the build folder worked for me.

Select "Clean Build Folder" option from "Product" menu.

ButterflyRay
  • 395
  • 2
  • 11
0

So, I have solved this by deleting pods which is related to Fabric, because it was conflicting with Crashlitics pod, since they actually duplicate each other, because Fabric it's just old version of Crashlitics

Georgy Ivanov
  • 39
  • 1
  • 4
0

My issue with this error was the Podfile. I'm using Firebase and one of their pods was the problem.

  1. I removed all firebase pods from the Podfile
  2. Deleted the derived data by running this code in the terminal. rm -rf ~/Library/Developer/Xcode/DerivedData/
  3. then reinstalled the pods I needed one by one.
wwarren07
  • 17
  • 9
0

If you are still unable to resolve this issue, try Product > Clean Build Folder ...

That's the only thing that worked for me.

TrappinNachos
  • 87
  • 1
  • 7
-1

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

Anderson Bressane
  • 378
  • 1
  • 5
  • 15