Xcode - Linker command failed with exit code - ios

Got a strange issue from Xcode, there aren't code issues and I haven't any idea how to handle with this problem. I also used Google and saw similar questions but the answers weren't useful for me.
duplicate symbol _OBJC_IVAR_$_Level._name in:
..../Library/Developer/Xcode/DerivedData/MobileMaps-bfaaljugbcgusoazfkvdbpbdyiqf/Build /Intermediates/MobileMaps.build/Debug-iphonesimulator/MobileMaps.build/Objects-normal/i386/Level-C98F33E28EFA5297.o
/Library/Developer/Xcode/DerivedData/MobileMaps-bfaaljugbcgusoazfkvdbpbdyiqf/Build/Intermediates/MobileMaps.build/Debug-iphonesimulator/MobileMaps.build/Objects-normal/i386/Level-C635B4AD47A32079.o
duplicate symbol _OBJC_IVAR_$_Level._type in:
...../Library/Developer/Xcode/DerivedData/MobileMaps-bfaaljugbcgusoazfkvdbpbdyiqf/Build/Intermediates/MobileMaps.build/Debug-iphonesimulator/MobileMaps.build/Objects-normal/i386/Level-C98F33E28EFA5297.o
...../Library/Developer/Xcode/DerivedData/MobileMaps-bfaaljugbcgusoazfkvdbpbdyiqf/Build/Intermediates/MobileMaps.build/Debug-iphonesimulator/MobileMaps.build/Objects-normal/i386/Level-C635B4AD47A32079.o
duplicate symbol _OBJC_IVAR_$_Level._binaryImage in:
...../Library/Developer/Xcode/DerivedData/MobileMaps-bfaaljugbcgusoazfkvdbpbdyiqf/Build/Intermediates/MobileMaps.build/Debug-iphonesimulator/MobileMaps.build/Objects-normal/i386/Level-C98F33E28EFA5297.o
..../Library/Developer/Xcode/DerivedData/MobileMaps-bfaaljugbcgusoazfkvdbpbdyiqf/Build/Intermediates/MobileMaps.build/Debug-iphonesimulator/MobileMaps.build/Objects-normal/i386/Level-C635B4AD47A32079.o
duplicate symbol _OBJC_CLASS_$_Level in:
..../Library/Developer/Xcode/DerivedData/MobileMaps-bfaaljugbcgusoazfkvdbpbdyiqf/Build/Intermediates/MobileMaps.build/Debug-iphonesimulator/MobileMaps.build/Objects-normal/i386/Level-C98F33E28EFA5297.o
... ../Library/Developer/Xcode/DerivedData/MobileMaps-bfaaljugbcgusoazfkvdbpbdyiqf/Build/Intermediates/MobileMaps.build/Debug-iphonesimulator/MobileMaps.build/Objects-normal/i386/Level-C635B4AD47A32079.o
duplicate symbol _OBJC_METACLASS_$_Level in:
...Library/Developer/Xcode/DerivedData/MobileMaps-bfaaljugbcgusoazfkvdbpbdyiqf/Build/Intermediates/MobileMaps.build/Debug-iphonesimulator/MobileMaps.build/Objects-normal/i386/Level-C98F33E28EFA5297.o
......Library/Developer/Xcode/DerivedData/MobileMaps-bfaaljugbcgusoazfkvdbpbdyiqf/Build/Intermediates/MobileMaps.build/Debug-iphonesimulator/MobileMaps.build/Objects-normal/i386/Level-C635B4AD47A32079.o
ld: 5 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)

From what I've read there are many different reasons for this problem and therefore many different solutions but maybe someone will have done the same stupid thing as me and this will help them. I am fairly certain this is not the problem the OP experienced though as my duplicate symbols were in differently named .o files.
Basically be very careful with autocorrect when typing your #import statements. I accidentally imported the .m file instead of the proper .h file and ended up with output similar to what the OP has posted.
Hope this helps somebody!

Related

Build iOS project got duplicate symbols for architecture i386 error

I'm using paho MQTT library in my project.
And when I build the project on simulator , I got the following errors.
duplicate symbol _client_version_eye in:
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTClient.o
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTAsync.o
duplicate symbol _Log_levels in:
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTPacket.o
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTAsync.o
duplicate symbol _Log_levels in:
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTPacket.o
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTProtocolClient.o
duplicate symbol _Log_levels in:
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTPacket.o
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/Socket.o
duplicate symbol _Log_levels in:
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTPacket.o
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTPersistence.o
duplicate symbol _Log_levels in:
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTPacket.o
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/Thread.o
duplicate symbol _Log_levels in:
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTPacket.o
/Users/xieweizhi/Library/Developer/Xcode/DerivedData/mgiosapp-bctgnqpjhalyqageaduowfwrsrkh/Build/Intermediates/mgiosapp.build/Debug-iphonesimulator/mgiosapp.build/Objects-normal/i386/MQTTProtocolOut.o
ld: 25 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
MQTTClient.c and MQTTAsync.c should not be included in the same project. They are used to build different libraries. Decide whether you want the blocking or async behaviour and use that file.
Try it....
The error may occur when you copy and paste the contents of one file to another file with its interface name which means two classes with same interface name.
In your code you have two different files with the same Interface name.
The problem is most likely due to a typo when including the header.
Check so that the header file (.h) is included and not the implementation file (.m).
Also Clean your project and build folder sometimes it will also solve this error
Also delete the derived data.

8 duplicate symbols for architecture i386

My app was working fine but after some modification I am getting following error please help me ......
duplicate symbol _OBJC_IVAR_$_MBThirdViewController.nameLabel1 in:
/Users/major/Library/Developer/Xcode/DerivedData/sideMenu- bslwsbjqbjtkojeslptbkyhajajv/Build/Intermediates/sideMenu.build/Debug- iphonesimulator/sideMenu.build/Objects-normal/i386/MBThirdViewController- D5D149C1AA17C975.o
duplicate symbol _OBJC_IVAR_$_MBThirdViewController.phoneLabel1 in:
/Users/major/Library/Developer/Xcode/DerivedData/sideMenu-bslwsbjqbjtkojeslptbkyhajajv/Build/Intermediates/sideMenu.build/Debug- iphonesimulator/sideMenu.build/Objects-normal/i386/MBThirdViewController-D5D149C1AA17C975.o
duplicate symbol _OBJC_IVAR_$_MBThirdViewController.emailLabel1 in:
/Users/major/Library/Developer/Xcode/DerivedData/sideMenu-bslwsbjqbjtkojeslptbkyhajajv/Build/Intermediates/sideMenu.build/Debug-iphonesimulator/sideMenu.build/Objects-normal/i386/MBThirdViewController-D5D149C1AA17C975.o
duplicate symbol _OBJC_IVAR_$_MBThirdViewController.photoView1 in:
/Users/major/Library/Developer/Xcode/DerivedData/sideMenu- bslwsbjqbjtkojeslptbkyhajajv/Build/Intermediates/sideMenu.build/Debug- iphonesimulator/sideMenu.build/Objects-normal/i386/MBThirdViewController- D5D149C1AA17C975.o
duplicate symbol _OBJC_IVAR_$_MBThirdViewController.imageVC in:
/Users/major/Library/Developer/Xcode/DerivedData/sideMenu- bslwsbjqbjtkojeslptbkyhajajv/Build/Intermediates/sideMenu.build/Debug- iphonesimulator/sideMenu.build/Objects-normal/i386/MBThirdViewController- D5D149C1AA17C975.o
duplicate symbol _OBJC_IVAR_$_MBThirdViewController.dataObject in:
/Users/major/Library/Developer/Xcode/DerivedData/sideMenu-bslwsbjqbjtkojeslptbkyhajajv/Build/Intermediates/sideMenu.build/Debug-iphonesimulator/sideMenu.build/Objects-normal/i386/MBThirdViewController-D5D149C1AA17C975.o
duplicate symbol _OBJC_CLASS_$_MBThirdViewController in:
/Users/major/Library/Developer/Xcode/DerivedData/sideMenu-bslwsbjqbjtkojeslptbkyhajajv/Build/Intermediates/sideMenu.build/Debug- iphonesimulator/sideMenu.build/Objects-normal/i386/MBThirdViewController- D5D149C1AA17C975.o
duplicate symbol _OBJC_METACLASS_$_MBThirdViewController in:
/Users/major/Library/Developer/Xcode/DerivedData/sideMenu- bslwsbjqbjtkojeslptbkyhajajv/Build/Intermediates/sideMenu.build/Debug- iphonesimulator/sideMenu.build/Objects-normal/i386/MBThirdViewController- D5D149C1AA17C975.o
ld: 8 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Go to Build Setting and search for No Common Blocks and set it NO. And build again you will not get this error again.
Make sure that the ViewController is not added twice in your project.
OR
you have declared same variable more than once.
Also got to Xcode->Window->Organizer->Projects
And Delete derived data
Hope that might help.
check if this MBThirdViewController is added twice in your project.
OR
remove the reference to it and try adding it again to your project.

ld: 8 duplicate symbols for architecture i386

I gone through question already asked on forum. Getting error as below
ld: 8 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
More error description is below
ld: warning: directory not found for option '-L/Users/Documents/Sprint1/iPhone/MyApplication/MyApplication/lib/lib'
ld: warning: directory not found for option '-Lrestkit'
ld: warning: ignoring file /Users/Documents/Sprint1/iPhone/MyApplication/MyApplication/lib/lib restkit/libRestKit.a, missing required architecture i386 in file /Users/Documents/Sprint1/iPhone/MyApplication/MyApplication/lib/lib restkit/libRestKit.a (2 slices)
duplicate symbol _OBJC_IVAR_$_Reachability.reachabilityRef in:
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Intermediates/MyApplication.build/Debug-iphonesimulator/MyApplication.build/Objects-normal/i386/Reachability.o
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Products/Debug-iphonesimulator/libPOSNirvanaUtils.a(Reachability.o)
duplicate symbol _kReachabilityChangedNotification in:
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Intermediates/MyApplication.build/Debug-iphonesimulator/MyApplication.build/Objects-normal/i386/Reachability.o
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Products/Debug-iphonesimulator/libPOSNirvanaUtils.a(Reachability.o)
duplicate symbol _kInternetConnection in:
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Intermediates/MyApplication.build/Debug-iphonesimulator/MyApplication.build/Objects-normal/i386/Reachability.o
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Products/Debug-iphonesimulator/libPOSNirvanaUtils.a(Reachability.o)
duplicate symbol _kLocalWiFiConnection in:
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Intermediates/MyApplication.build/Debug-iphonesimulator/MyApplication.build/Objects-normal/i386/Reachability.o
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Products/Debug-iphonesimulator/libPOSNirvanaUtils.a(Reachability.o)
duplicate symbol _OBJC_IVAR_$_Reachability.key_ in:
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Intermediates/MyApplication.build/Debug-iphonesimulator/MyApplication.build/Objects-normal/i386/Reachability.o
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Products/Debug-iphonesimulator/libPOSNirvanaUtils.a(Reachability.o)
duplicate symbol _OBJC_CLASS_$_Reachability in:
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Intermediates/MyApplication.build/Debug-iphonesimulator/MyApplication.build/Objects-normal/i386/Reachability.o
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Products/Debug-iphonesimulator/libPOSNirvanaUtils.a(Reachability.o)
duplicate symbol _OBJC_METACLASS_$_Reachability in:
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Intermediates/MyApplication.build/Debug-iphonesimulator/MyApplication.build/Objects-normal/i386/Reachability.o
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Products/Debug-iphonesimulator/libPOSNirvanaUtils.a(Reachability.o)
duplicate symbol _kConnectionDown in:
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Intermediates/MyApplication.build/Debug-iphonesimulator/MyApplication.build/Objects-normal/i386/Reachability.o
/Users/Library/Developer/Xcode/DerivedData/MyApplication-bchgbqjzuwjzbcbnhwyihhatsoyw/Build/Products/Debug-iphonesimulator/libPOSNirvanaUtils.a(Reachability.o)
ld: 8 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I have project structure like
Application
Static library A
Static library B
Situation
1) Static library A depend on static library B. The project A require Reachability check.
2) Added static library A into Application project
3) When I compile,getting linker error
Please help to resolve this issue.
If this solution is not working then check this..
Another reason this error often happens is accidentally importing the .m file instead of the .h.
Steps:
1.Check Build phases in Target settings.
2.Check if any file exists twice or once.
3.If file exist twice delete one. If not delete file in the bottom which is the latest one.
4.Build again.
You have Reachability class in libPOSNirvanaUtils.a & your Application and you are using libPOSNirvanaUtils.a in your application. So now your application has 2 reference of Reachability class.
If you are building libPOSNirvanaUtils.a then you can solve this with 2 ways:
Remove Reachability class membership from target libPOSNirvanaUtils.a
Add Reachability class in Copy files, remove Reachability class reference from your Application and use same class reference from libPOSNirvanaUtils.
I had the same problem while using prepareforsegue delegate. It turns out, I accidentally imported the .m file instead of the .h file. This will fix it. Look at your #import statements before you go crazy adding and deleting frameworks.
In my case I got this error because had the same named variables declared in several files in implementation part.
#implementation A
int a;
...
#implementation B
int a;
...
gave me "duplicate symbol _a ..."

iOS - Circular Imports - fixing blocks and typedef enums

I am getting an error that this block, which I defined in a header file, has 78 duplicate symbols. I have tried putting it in the precompiled header file but I still get the same results.
This is the error: ld: 34 duplicate symbols for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
It's possible that there are some circular imports, but I can't really change a lot unless anyone has a way to forward define a typedef enum (which I have used all throguhout the project) - something like #class but for typedef.
Can anyone please help?

duplicate symbol for architecture x86_64

I am facing duplicate symbols issue during use of Core plot API and ESRI map Arc GIS API.
In my app I am using Core plot and ArcGIS API. To provide support for 64 bit device, I have download new API for ArcGI (ESRI map) and accordingly update CorePlot API for 64 bit. After making changes I am facing issue:
error description are here:
duplicate symbol _squareOfDistanceBetweenPoints in:
/Users/xxxx/Library/SDKs/ArcGIS/iOS/ArcGIS.framework/ArcGIS(AGSCPTUtilities.o)
/Users/xxxx/Desktop/18 Nov/SCM_iPad/SCM/CorePlot/coreplot_new.a(CPTUtilities.o)
duplicate symbol _niceNum in:
/Users/xxxx/Library/SDKs/ArcGIS/iOS/ArcGIS.framework/ArcGIS(AGSCPTAxis.o)
/Users/xxxx/Desktop/18 Nov/SCM_iPad/SCM/CorePlot/coreplot_new.a(CPTAxis.o)
duplicate symbol _CreateRoundedRectPath in:
/Users/xxxx/Library/SDKs/ArcGIS/iOS/ArcGIS.framework/ArcGIS(AGSCPTPathExtensions.o)
/Users/xxxx/Desktop/18 Nov/SCM_iPad/SCM/CorePlot/coreplot_new.a(CPTPathExtensions.o)
duplicate symbol _AddRoundedRectPath in:
/Users/xxxx/Library/SDKs/ArcGIS/iOS/ArcGIS.framework/ArcGIS(AGSCPTPathExtensions.o)
/Users/xxxx/Desktop/18 Nov/SCM_iPad/SCM/CorePlot/coreplot_new.a(CPTPathExtensions.o)
duplicate symbol _MyCGPathApplierFunc in:
/Users/xxxx/Library/SDKs/ArcGIS/iOS/ArcGIS.framework/ArcGIS(NSCoderExtensions.o)
/Users/xxxx/Desktop/18 Nov/SCM_iPad/SCM/CorePlot/coreplot_new.a(NSCoderExtensions.o)
ld: 5 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
If anyone face issue please suggest. I am unable to figure out what is duplicate in those API Earlier these two working fine (OLD api without 64 bit support)
You might have imported the .m instead of the .h file
You might have added any Typedef function in .H file and have imported .H in many classes.
In my case it was an issue,
ShadowASettings ShadowSettingsMake(CGSize shadowSize, CGFloat shadowOpacity, CGFloat shadowRadius){
ShadowASettings settings;
settings.shadowOffset = shadowSize;
settings.shadowOpacity = shadowOpacity;
settings.shadowRadius = shadowRadius;
return settings;
}
I wrote this function in ABC.h
and then I imported ANC.h in my HomeVC.h and XYZ.h
So, then I simply move this function to .m of that class as it was only used in .m

Resources