I have opened .xcworkspace and when run application am getting clang: error: linker command failed with exit code 1 (use -v to see invocation) - objective-c

duplicate symbol _GTMNSDictionaryURLArgumentsExportToSuppressLibToolWarning in:
/Users/Varshana/Library/Developer/Xcode/DerivedData/Lodore-axtsfmjdyxbqyccujoquacrynsxv/Build/Products/Debug-iphonesimulator/GoogleToolboxForMac/libGoogleToolboxForMac.a(GTMNSDictionary+URLArguments.o)
/Users/Varshana/Documents/Lodore final stage/GoogleSignInDependencies.framework/GoogleSignInDependencies(GTMNSDictionary+URLArguments_aec9c2446af4c2ac5a7380b418b337ea.o)
duplicate symbol _kGTMOAuth2WebViewKey in:
/Users/Varshana/Library/Developer/Xcode/DerivedData/Lodore-axtsfmjdyxbqyccujoquacrynsxv/Build/Products/Debug-iphonesimulator/GTMOAuth2/libGTMOAuth2.a(GTMOAuth2Authentication.o)
/Users/Varshana/Documents/Lodore final stage/GoogleSignInDependencies.framework/GoogleSignInDependencies(GTMOAuth2Authentication_ad53759ab562393658e6c193e56628dd.o)
duplicate symbol _kGTMOAuth2ErrorRequestKey in:
/Users/Varshana/Library/Developer/Xcode/DerivedData/Lodore-axtsfmjdyxbqyccujoquacrynsxv/Build/Products/Debug-iphonesimulator/GTMOAuth2/libGTMOAuth2.a(GTMOAuth2Authentication.o)
/Users/Varshana/Documents/Lodore final stage/GoogleSignInDependencies.framework/GoogleSignInDependencies(GTMOAuth2Authentication_ad53759ab562393658e6c193e56628dd.o)

don't worry, just xcode bug. try clean and build and it will work, or better, go to xcode->preferences->location->Derived Data. delete all files inside derived data and then restart xcode. clean and build the project and then it will work perfectly
ps: updated for cleaning
Cmd + Shift + Alt + K
To check the exact error for this issue check following:
Select issue navigator > Click on error will show logs for error > In that select All Messages tab.
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

Related

Multiple attempts to fix Error: linker command failed with exit code 1

I've been working on this error for the last few days and am really stuck. I keep getting a linker command error and can't get past it. I've searched the web and tried all of the tips: Checked for duplicate files, reinstalled pods, set active architecture to NO, deleted derived data, cleaned lots of times.
Here's the output I'm given:
duplicate symbol _OBJC_IVAR_$_SessionPlayer._nextEvent in:
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayer.o
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayerViewController.o
duplicate symbol _OBJC_IVAR_$_SessionPlayer._visitors in:
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayer.o
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayerViewController.o
duplicate symbol _OBJC_IVAR_$_SessionPlayer._currentSessionTimeInMilliseconds in:
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayer.o
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayerViewController.o
duplicate symbol _OBJC_IVAR_$_SessionPlayer._systemTimeInMilliseconds in:
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayer.o
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayerViewController.o
duplicate symbol _OBJC_CLASS_$_SessionPlayer in:
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayer.o
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayerViewController.o
duplicate symbol _OBJC_METACLASS_$_SessionPlayer in:
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayer.o
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayerViewController.o
duplicate symbol _OBJC_IVAR_$_SessionPlayer._isPlaying in:
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayer.o
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayerViewController.o
duplicate symbol _OBJC_IVAR_$_SessionPlayer._useTiming in:
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayer.o
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayerViewController.o
duplicate symbol _OBJC_IVAR_$_SessionPlayer._delegate in:
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayer.o
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayerViewController.o
duplicate symbol _OBJC_IVAR_$_SessionPlayer._timeline in:
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayer.o
/Users/user1/Library/Developer/Xcode/DerivedData/***-APP-NAME-bahimtombyapwkcekphmmbaifpqx/Build/Intermediates/***-APP-NAME.build/Debug-iphonesimulator/***-APP-NAME.build/Objects-normal/x86_64/SessionPlayerViewController.o
ld: 10 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Really not sure what to do, it's very frustrating.
EDIT: Made the discovery that all of my files are being compiled twice, which may be where the problem lies.
It sounds like you've included the source for SessionPlayer.m twice in your target's build. Based on some comments, it's likely because you have references to the file implicitly through a pod (which is what you want), and explicitly via a direct reference/inclusion (which you don't want; that's what the pods are for). Try doing the following (and I'll try to be as clear as I can in text, but if you have any questions I can include screenshots):
In the project navigator pane, select your project.
In the project editor window, select your app target (make sure it's not something like a UnitTest/LogicTest target).
Along the top of the project editor window, select "Build Phases"
In the main project editor window, there should now be a list of expandable sections, one of which is "Compile Source (xxx items)", where xxx is the number of source files used to build your target. Expand that section.
In the search/filter text field (upper right hand corner of project editor, placeholder text says "Filter"), enter "SessionPlayer"
I suspect that you've included SessionPlayer.m explicitly here, so you should see at least one instance in the list. Delete it by selecting the "-" button that appears at the bottom of the list.
Try rebuilding and see if at least the linker errors related to SessionPlayer.m disappear. If so, repeat the previous steps for any other such files.
Hope this helps.

typedef in separate header file

I have a defines.h file with following code
typedef enum AnswerType : NSUInteger {
kAnswerTypeNotResponded = 0,
kAnswerTypeYes = 1,
kAnswerTypeNo = 2,
kAnswerTypeComplain = 3
} AnswerType;
When I import this file in several other files - I get an error
ld: 13 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I need AnswerType be visible in many places. What is the best variant to implement it?
Your enum looks fine. However, I guess there should be another problem.
One of the major reason for occurrence of this issue is that you might have a file listed in build phases more then once. So you need to make sure that files are listed in build phases only once.
Here are the steps you can follow:
Check Build phases in Target settings.
Check if any file exists twice.
If file exist twice delete one. If not delete file in the bottom which is the latest one.
Build again.
Original source of answer
Just follow below steps and your issue is solved.
1. Go to Build Setting
2. Search for No Common Blocks and
3. Set it NO
4. Build again
5. You will not get this error again.

duplicate symbol _OBJC_CLASS_$_Reachability in:

duplicate symbol _OBJC_CLASS_$_Reachability in:
XYZMobileApp/Build/Intermediates/XYZMobileApp.build/Debug-iphonesimulator/XYZMobileApp.build/Objects-normal/x86_64/Reachability.o
XYZMobileApp/BusinessLogic/Library/XtifyLib/XtifyPush.embeddedframework/XtifyPush.framework/XtifyPush(Reachability.o)
I am getting this error:
duplicate symbol _OBJC_CLASS_$_Reachability in:
and
clang: error: linker command failed with exit code 1 (use -v to see invocation)
you have used Reachablity class two times in your code.
One is included in the framework XtifyPush.framework and other you have included in the bundle.
Remove the one you are adding to remove the duplicacy.
Make sure that you did not include the Reachability.m -> implementation file instead of Reachability.h-> header file.
And also make sure you didn't include Reachability in you your unit test target this can also cause issues.
I renamed Reachability class as well as filename in library to "MyReachability". Xcode asked me to unlock the file as it was under pod. I unlocked it and after building i got few errors in my framework that Reachability class not found. I renamed the class references there as well to MyReachability and it worked fine. Hope this helps.

Apple Mach-O Linker Error: Duplicate Symbols. I renamed my project and this happened

I've been reading up on various linker errors on Stack Overflow for awhile now, and each seem to be a bit different. I'm hoping you might have insight into the one I'm getting.
I've got the following... (issue only exists in simulator. It's fine on device.)
Apple Mach-O Linker Error
ld: 192 duplicate symbols for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
There are 2 errors for every file...
duplicate symbol _CATEGORIES in:
/Users/me/Library/Developer/Xcode/DerivedData/Roto_Forum-ahulcvyneocizdcbjsdtiqgknlhk/Build/Intermediates/Roto Forum.build/Debug-iphonesimulator/Roto Forum.build/Objects-normal/x86_64/FFFMainBodyViewController.o
/Users/me/Library/Developer/Xcode/DerivedData/Roto_Forum-ahulcvyneocizdcbjsdtiqgknlhk/Build/Intermediates/Roto Forum.build/Debug-iphonesimulator/Roto Forum.build/Objects-normal/x86_64/Item.o
duplicate symbol _POINTS in:
/Users/me/Library/Developer/Xcode/DerivedData/Roto_Forum-ahulcvyneocizdcbjsdtiqgknlhk/Build/Intermediates/Roto Forum.build/Debug-iphonesimulator/Roto Forum.build/Objects-normal/x86_64/FFFMainBodyViewController.o
/Users/me/Library/Developer/Xcode/DerivedData/Roto_Forum-ahulcvyneocizdcbjsdtiqgknlhk/Build/Intermediates/Roto Forum.build/Debug-iphonesimulator/Roto Forum.build/Objects-normal/x86_64/Item.o
That's 2 of the 192 errors. If I look at my Compile Sources under the Build Phases of my Target, FFFMainBodyViewController.m is the first file. Item.m is the second. And for each and every file down the list, in order, I get a 2 duplicate errors like the ones seen above.
This all started I believe when I renamed my project, and therefore the target name in my Podfile also changed.
I've tried various things. Deleting Derived Data, Cleans, deleting the red libPods.a file from my framework, etc.
How might I solve this issue?

Code does not compile for extra large implementation file

The compiler exits by throwing following error.
/var/folders/2t/jkh9ngsn6f9bnmz8l0mz0zm80000gs/T/xsdLocal20-ZhAiH9.s:1895977:branch out of range
clang: error: assembler command failed with exit code 1 (use -v to see invocation)
Command /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang failed with exit code 1
The file has 98341 number of lines.
using compiler Apple LLVM 3.1
The code builds for simulator but not for iOS device
Save the original file.
Comment out out #implementation after another, til the file compiles properly. Npw you know the class that is giving you the problem.
Then take the very biggest method, adding '#if 0' around the code, and at the top before the '#if 0', return a proper value - YES, NO, nil, whatever so the file will compile.
Compile. Do you still get the problem? Then comment out the next largest method, or just do the methods sequentially, or use a binary search technique (ie comment out one half of the methods, then the other half, to drill down on the culprit.
Once you find the problem method, you will need to refactor it into two or more methods, which probably can be private to the class, so your public interface does not change.