Duplicate symbols for architecture x86_64 under Xcode
Solution 1
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 2
For me, changing 'No Common Blocks' from Yes to No ( under Targets->Build Settings->Apple LLVM - Code Generation ) fixed the problem.
Solution 3
Stupid one, but make sure you haven't #import
ed a .m
file by mistake somewhere
Solution 4
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
I have same problem. In Xcode 7.2 in path Project Target > Build Setting > No Common Blocks, i change it to NO.
Related videos on Youtube
![lee](https://i.stack.imgur.com/YO5Z0.jpg?s=256&g=1)
Comments
-
lee about 2 years
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 theOther Linker Flags
. After remove this value then I can build my project successfully, but I don't know why. Can anyone explain this?-
ravron about 10 yearsThe 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. -
lee about 10 yearsthis 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 about 10 yearsit's not your case, cause before I add the sdk of google my project build ok.
-
Bogdan over 8 yearsSecond answer from Adam Waite is really straight forward. Make sure there is no .m file #imported somewhere.
-
Hope almost 8 yearsIn 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.
-
doxsi over 7 yearsMake sure you #include a .h file, not a .m.
-
Alok over 7 yearstry this : stackoverflow.com/a/42089897/3024579
-
David Ferris over 6 yearsA very similar error is thrown by accidentally including a
.cpp
file instead of it's corresponding header file.hpp
! -
Hanz Cheah about 6 yearsI 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. stackoverflow.com/questions/49669403/…
-
yuchen over 2 yearsWorked perfect for me!
-
-
Reuben Tanner over 9 yearsIn other words, make sure you remove any object files in your xcode project.
-
JanB over 9 yearsHuge 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.
-
user1244109 almost 9 yearsthis solved the issue for me. Although i prefixed
extern
instead ofstatic
:extern NSString * const kNotificationName;
. Which is strange, because u usually did not add such prefix, and it worked fine.. -
Hemang almost 9 yearsThis solved my problem. Is it ever require to change it back to
NO
? What's the reason behind this ? -
Linda MacPhee-Cobb almost 9 yearsIf 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 )
-
bgplaya over 8 yearsHey, 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! -
Allison over 8 yearsThis, 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.
-
Sauvik Dolui over 8 years@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. :(
-
Fatlad over 8 yearsthis was my problem as well why is the actual problem caused by this?
-
Steven A. Lowe over 8 yearssmall helper function, accidentally copied, easily overlooked - thanks!
-
coco over 8 yearsYes 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.
-
Oktay over 8 yearsNot const but it worked for me when I change variable name
-
trojanfoe over 8 yearsThis 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. -
Yawar about 8 yearsI don't know why someone downvoted you, this solved my issue.
-
Sunil Targe almost 8 yearsIt 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? -
David V almost 8 yearsI 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.
-
Mark24x7 over 7 yearsSame thing fixed it for me, when I switched enum to typedef NS_ENUM it fixed the duplicate symbols error
-
pkamb over 7 yearsXcode 8 prompted this change as one of its automatic updates and broke my build :/
-
Scooter over 7 yearsI 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.
-
Pankaj Yadav over 7 yearsCase 2nd saved me a night. Thanks!
-
vib over 7 yearsbut why? same happened to me with plain C functions with same names
-
Zoltán over 7 yearsYeah, this helped me. Xcode 8, updated an older project to recommended settings. Switched this back and I'm good to go again. Thanks!
-
Helen Wood over 7 yearsGood job. Helped me a lot! An up vote for you darling! ;-)
-
onekiloparsec over 7 yearsSame here for Xcode8.2.1, when applied to an old project.
-
Coty Embry about 7 yearsI 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
-
Manish Pathak about 7 yearsAfter spending 2 hour, this issue has been resolved because of this answer. Thanks
-
Muju almost 7 yearsWorked for me as well. Thanks.
-
Bruno Muniz almost 7 yearsWhen 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.
-
Ky - almost 7 years@user1244109
static
is for when you actually have a value (static NSString * kFoo = @"Foo";
) andextern
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 usingFOUNDATION_EXPORT
because it adapts to different compilation environments (ObjC, ObjC++, Win32, etc.) -
Daniel Lima over 6 yearsThank you so much for enlightening my mind for the possibility that I made such a stupid mistake.
-
ammianus over 6 yearsI had this with a pointer of my own class variable defined in the @implementation of two different classes
-
Burf2000 over 6 yearsBrilliant mate :)
-
Axeman over 6 yearsXcode 9 automatically changed it in automatic update of an old project. Restored to "NO" and build succeeded.
-
kas-kad over 6 yearsalso 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. -
Ravi over 6 yearsIn my case I have import .m file. So stupid mistake. Once I imported .h file. It is ready for build!! Thanks
-
PANKAJ VERMA over 6 yearsAt 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
-
Abdullah Nurum over 6 yearsFantastic. I wasted two days to solve this problem. This worked for me. Thanks a lot.
-
Nooblhu about 6 yearsThis works, but I had to change it in target and project
-
Shivani Gor about 6 yearsAfter spending my whole day, this issue has been resolved because of this answer. Thanks a lot!!!
-
swift2geek almost 6 yearsThank you man!!!!, it solved my issue. 4 days of removing duplicates....and bam - this solution
-
Tina almost 6 yearsAfter searching for an hour,This answer helped me a lot Thanks
-
noveleven over 5 yearshow about cross-project import .m file?
-
Baran Emre about 5 yearsHad the same problem here. Your post helped me. Thanks!
-
I make my mark almost 5 yearsWhat does it do?
-
CJ_COIMBRA over 4 yearsAdd a couple more hours to that.
-
LowFieldTheory over 4 yearsThis fixed it on XCode 11.3.1 too
-
Kilo Loco over 4 yearsI'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. Runpod install
4. Uncomment your pods in the Podfile 5. Runpod install
again 6. Profit -
Kasey over 4 years@kiloLoco Yeah I think it's a bug in Xcode? Maybe I'm wrong.
-
foufrix over 4 yearsIn xcode 10 it's now under Apple Clang - Code Generation Thanks !
-
BVB09 about 4 yearsThis 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.
-
tong about 4 yearsThanks! In my case I compiled two main.m where one was the old reference. This was caused by drag and drop.
-
Naresh almost 4 yearswhich is only for class files like .h, .m or .swift files. Not for frame work level files.
-
shokaveli over 3 yearsThis is the answer! SwiftUI previews was not working for me until I made this change. Thx sir!
-
Chandni over 3 yearsWhere can I have this option?
-
bdroid over 3 yearsLegacy Build System Deprecated
-
Farras Doko over 3 yearsJust need to import
.h
file 🙃 -
Bitlejuce Do about 3 yearsI had to rename even local variables @implementation DIOOutstreamVideoView CGFloat visibleHeightOut; CGFloat fullHeightOut;
-
Jafar Jabr over 2 yearsThank you, it didn't solve my problem but decreased the duplications from 14 to 9
-
Jafar Jabr over 2 yearsthe rest solved by removing "use_flipper!()" from podFile
-
Kalamarico over 2 yearsI'm glad to hear that!! And thanks for your input!
-
Josue Gisber about 2 yearsThis 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.
-
Just a coder about 2 yearsThat 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.
-
Tim Sonner about 2 yearsI 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.
-
Anirban Das about 2 yearsThanks! man. Atlast for your answer I'm able to run the app for first time... Thank you very much!!!