问题
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?
回答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
回答2:
For me, changing 'No Common Blocks' from Yes to No ( under Targets->Build Settings->Apple LLVM - Code Generation ) fixed the problem.
回答3:
Stupid one, but make sure you haven't #import
ed a .m
file by mistake somewhere
回答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";
回答5:
I have same problem. In Xcode 7.2 in path Project Target > Build Setting > No Common Blocks, i change it to NO.
回答6:
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 :)
回答7:
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
回答8:
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.
回答9:
Fastest way to find the duplicate is:
- Go to Targets
- Go to Build Phases
- Go to Compile Sources
- Delete duplicate files.
回答10:
Remove -ObjC from Other Linker Flags or Please check you imported any .m file instead of .h by mistake.
回答11:
Following steps solved the issue for me.
- Go to Build Phases in Target settings.
- Go to “Link Binary With Libraries”.
- Check if any of the libraries exist twice.
- Build again.
回答12:
Defining same variable under @implementation in more than one class also can cause this problem.
回答13:
In my case, there were two file by same name in the location
Targets > Build Phases > Compile Sources and delete any duplicate files.
回答14:
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.
回答15:
- Go to Targets
- Select Build Settings
- Search for "No Common Blocks", select it to NO.
It worked for me
回答16:
For me during the Xcode8 recommended project settings update "No Common Blocks" to YES which causes this issue.
回答17:
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.
回答18:
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 :
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
回答19:
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.
回答20:
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.
回答21:
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> {
...
...
回答22:
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.
回答23:
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:
Declare it as static, to limit the scope to class:
static BOOL myVar = NO;
Remove the initialization (which will make the two classes share the global var):
BOOL myVar; -(void) init{ myVar = NO; }
Declare it as a property:
@property BOOL myVar;
Declare it as a proper iVar in the @interface
@interface myClass(){ BOOL myVar; } @end
回答24:
In my case I had two main()
methods defined in my project and removing one solved the issue.
回答25:
Same issue happen with me, when I was integrating the lob project inside my project.
Actually lob project also have the AFNetworking files, So I remove the .m files from lob project.
Actually .m files are conflicting with My project POd/AFNetworking/ .m files
回答26:
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.
回答27:
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.
回答28:
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.
回答29:
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
回答30:
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.
来源:https://stackoverflow.com/questions/24298144/duplicate-symbols-for-architecture-x86-64-under-xcode