Conflicting libraries in iOS project - ios

So basically I have two libraries that are I think conflicting with each other. I have the following settings for the key "Library Search path":
"$(SRCROOT)/projectname/Release-iphone/lib" for one of my libraries, and "$(SRCROOT)/projectname" for another.
I have added a CorePlot library into my project but to work it requires the following Linker Flags: -ObjC -all_load.
Now when I add one or both of them I get the following message and my project won't build:
duplicate symbol _OBJC_CLASS_$_GTMHTTPFetcher in:
/Users/user/Library/Developer/Xcode/DerivedData/projectname-chibchblpntaapfagqcohtkixhib/Build/Intermediates/projectname.build/Debug-iphoneos/projectname.build/Objects-normal/armv7/GTMHTTPFetcher.o
/Users/user/Dropbox/Projectname/projectname/projectname/libGTLTouchStaticLib.a(GTMHTTPFetcher.o)
duplicate symbol _OBJC_METACLASS_$_GTMHTTPFetcher in:
/Users/user/Library/Developer/Xcode/DerivedData/projectname-chibchblpntaapfagqcohtkixhib/Build/Intermediates/projectname.build/Debug-iphoneos/projectname.build/Objects-normal/armv7/GTMHTTPFetcher.o
/Users/user/Dropbox/Projectname/projectname/projectname/libGTLTouchStaticLib.a(GTMHTTPFetcher.o)
ld: 176 duplicate symbols for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
The problem turns out to be with the Google API library libGTLTouchStaticLib.a but I don't get how do linker flags influence it.

It looks as though you have the source file included directly into your project as well as having a link to the library. You should choose one or the other (probably the library).

screw -all_load that was a hack to load categories. should work without it

Related

ld: 1 duplicate symbol for architecture arm64, two SDK in swift3

Hi I working with two 2 SDK , moca and sentencie,
now the problem is when compile Xcode show me:
duplicate symbol _kReachabilityChangedNotification in:
/Users/dortiz/Documents/IOS/ProcIOS/Pods/MOCA/libMOCALib.a(APPLReachability.o)
/Users/dortiz/Documents/IOS/ProcIOS/Frameworks/SENTTransportDetectionSDK.framework/SENTTransportDetectionSDK(Reachability.o)
ld: 1 duplicate symbol for architecture arm64 clang: error: linker
command failed with exit code 1 (use -v to see invocation)
The problem is I can't edit Reachability.o or APPLReachability.o
because, are libraries, what I can do to fix it?
There are many solution you can try out :-
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.
Changing 'No Common Blocks' from Yes to No ( under Targets->Build Settings->Apple LLVM - Code Generation ) fixed the problem.
Please check your imported any .m file instead of .h by mistake.

Contradicting frameworks on -ObjC

So in my project I have the FacebookSDK, the ParseSDK and FirebaseSDK. Facebook and parse both need bolts, so I implemented that. However it will not compile unless I remove the -ObjC flag. The problem is that if I remove this tag, the code will compile, but It will cause a runtime error when trying to initialise Firebase because it requires -ObjC. I am in a mess. Can I set the flag only for that specific framework? Thanks for any help.
( I think this should be a comment, but I don't have enough rep yet, hope this helps to solve this.)
I'm having the exact same problem (with SponsorPay SDK instead of FirebaseSDK), Facebook SDK & Parse work fine together until i add the -ObjC flag, needed by SponsorPay to work.
Deleting Bolts.framework is not the solution, since that gives some linking errors:
"_BFTaskMultipleExceptionsException", referenced from:
___53+[PFObject(Private) deleteAllAsync:withSessionToken:]_block_invoke214 in Parse(PFObject.o)
___65+[PFObject(Private) _deepSaveAsync:withCurrentUser:sessionToken:]_block_invoke311 in Parse(PFObject.o)
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I get the exact same error if I use the Bolts.framework included in the FacebookSDK package.
But, using the Bolts.framework included in the Parse Library I got a different error:
ld: 91 duplicate symbols for architecture x86_64
All frameworks and libraries are updated.
EDIT:
Using cocoapods solved the problem for me too!
See: FacebookSDK and Bolts conflicting each other (duplicate symbols) on build.
I would suspect that Facebook is broken, and is including bolts itself. No thirdparty framework should include another thirdparty framework, since it leads to exactly this. All third-party frameworks should be linked at the final application stage. Go into any frameworks that link their own sub-libraries, and remove the sub-sublibraries (and open bugs against the offenders).

duplicate symbols for architecture i386 - Error during adding custom framework

I'm trying to add a custom framework into 2 projects but an error occurred.
duplicate symbol _OBJC_CLASS_$_ApiECV in:
/Users/kevinmachado/Library/Developer/Xcode/DerivedData/EnvDevTestiPad-bvscnxvnzjltpxcxuoomuaqqsxpj/Build/Products/Debug-iphonesimulator/libAPI_ECV.a(ApiECV.o)
/Users/kevinmachado/Library/Developer/Xcode/DerivedData/EnvDevTestiPad-bvscnxvnzjltpxcxuoomuaqqsxpj/Build/Products/Debug-iphonesimulator/libMKCalendar.a(ApiECV.o)
duplicate symbol _OBJC_METACLASS_$_ApiECV in:
/Users/kevinmachado/Library/Developer/Xcode/DerivedData/EnvDevTestiPad-bvscnxvnzjltpxcxuoomuaqqsxpj/Build/Products/Debug-iphonesimulator/libAPI_ECV.a(ApiECV.o)
/Users/kevinmachado/Library/Developer/Xcode/DerivedData/EnvDevTestiPad-bvscnxvnzjltpxcxuoomuaqqsxpj/Build/Products/Debug-iphonesimulator/libMKCalendar.a(ApiECV.o)
ld: 2 duplicate symbols for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I think this error is coming because I try to compile twice my custom framework.
I have 3 projects on my workspace. API_ECV and iPadTest are both calling MKCalendar as framework
You can take a look here :
iPadTest build phase :
API_ECV build phase :
If I delete the link in API_ECV no error occurred but I can't use MKCalendar framework
Anyone have an idea ? Can I link my custom framework without compiling it twice ?
Thx ;)
You have two choices:
For a simple dependency like yours, just remove libMKCalendar.a from either iPadTest or API_ECV. Then it will be linked exactly once. (You would need to specify path to its headers were the compiler to have problems).
If you have more complicated dependencies, just turn MKCalendar into a framework, then it can be intelligently reused by different targets. iOS frameworks are available if you use Xcode 6 beta.
From what you posted, I guess that:
API_ECV linked from MKCalendar
API_ECV linked from iPadTest
MKCalendar linked from iPadTest
So here is where your duplicate comes from, API_ECV twice from direct link and MKCalendar link.
Two possible solutions:
Don't link it from iPadTest, relying on MKCalendar to provide it
Mark it as "Optional" in MKCalendar (Where is is mentioned "Required")

How to resolve the duplicate symbol in 3rd party Framework in ios?

I am developing the Amazon login and Google Plus share in my project. I added the Amazon and Google plus framework in my project. when i try to build project it show "Duplicate symbol in GooglePlus and Amazon Framework" error.
Error Message
duplicate symbol _kClientId in:
/Users/test/Amazon/Apps-SDK/iOS/LoginWithAmazon/LoginWithAmazon.framework/LoginWithAmazon(AIConstants.o)
/Users/test/GooglePlus/google-plus-ios-sdk-1.5.1/GooglePlus.framework/GooglePlus(GPPOzLogger.o)
ld: 1 duplicate symbol for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
How To resolve this kind of error?
All you can really do is contact Google and/or Amazon and tell them to fix their conflicting frameworks. It's kind of silly for both of them to use a global symbol name like _kClientId in their frameworks when the chances of a conflict happening with a name like that are extremely high. The names really should be something long like _kGooglePlus_iOS_Framework_ClientId and _kAmazon_iOS_Framework_ClientId for each respective framework to reduce the chances of symbol name collision.
Either do that or use a different framework or library for either Google Plus or Amazon, if you can. Or if you can't do that, use a HEX editor to manually change all references to the _kClientId symbol in one of the frameworks.
I have faced the same problem some times ago. And finally I have figured out how to solve this.
As a client of library we can not avoid it, but we still have chance to deal with it.
My Answer include two parts, one to describe the problem, one to solve this problem as a client of framework(That means we have to solve this by our own not ask the developer of framework to workout this).
1) How collision happened, and what does the link error mean?
A framework is a folder actually, enter the framework you will find a lib file. Sometimes the lib file have a extension of *.a or just have no extension. The structure of a lib file looks like below:
libFoo.a / i386 /
hello.o
world.o
arm64 /
hello.o
world.o
In this case a libFoo.a is a fat library, that means it contains several architectures in it. The link error is telling you that you have two libraries that contain the same .o(symbols) file in the same architecture.
for example of your case:
duplicate symbol _kClientId in:
/Users/test/Amazon/Apps-SDK/iOS/LoginWithAmazon/LoginWithAmazon.framework/LoginWithAmazon(AIConstants.o)
/Users/test/GooglePlus/google-plus-ios-sdk-1.5.1/GooglePlus.framework/GooglePlus(GPPOzLogger.o)
ld: 1 duplicate symbol for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
This means in the two frameworks, you have duplicate .o files in the i386 architecture.
2) How to solve the problem.
We need some tools to solve this. Lucky, you should have those tools installed in your computer.
What we need to do is to open a framework and do some surgery to remove duplicate symbol and close it up.
I demonstrate the process here to remove the duplicate symbol AIConstants.o in LoginWithAmazon under i386 architecture:
lipo -info LoginWithAmazon //this is going to show us the architectures in the fat library
lipo LoginWithAmazon -thin i386 -output LoginWithAmazon-i386 //we extract the i386 architecture as xxx-i386 from fat library
//use the same command to extract every architecture from fat libraray as xxx-archname
ar -t LoginWithAmazon-i386 // list of symbols in this architecture, we should see AIConstants.o in it
ar -d LoginWithAmazon-i386 AIConstants.o // delete AIConstants.o from LoginWithAmazon-i386
//now work is done, we put everything back to the fat library
lipo LoginWithAmazon-i386 LoginWithAmazon-arm64 <every architecture you extracted from the fat library> -create -output LoginWithAmazon-new
ranlib -s LoginWithAmazon-new //sometime we need to rebuild the symbol table
//now you have done the work, use LoginWithAmazon-new to replace the old LoginWithAmazon, and try to compile your program again
REF:
http://blog.sigmapoint.pl/avoiding-dependency-collisions-in-ios-static-library-managed-by-cocoapods/
Seems like this issue is not high priority for the login with amazon team.
As a temporary solution (believe it or not) you can use a text editor and replace all occurrences of "_kClientId" in the LoginWithAmazon binary with something else (like "_kClientIe").
See also my answer here:
https://github.com/aws/aws-sdk-ios/issues/18

Xcode gives Apple Mach-O linker error

I just compiled a project and Xcode returns these two errors which don't seem to be my code's fault. How do I fix them?
Undefined symbols for architecture i386:
"_vImageBoxConvolve_ARGB8888", referenced from:
-[UIImage(Blur) boxblurImageWithBlur:] in UIImage+Blur.o
ld: symbol(s) not found for architecture i386
clang: error: linker command failed with exit code 1 (use -v to see invocation)
Teaching a man (or women) how to fish:
Usually Mach-O Linker Error means you have not included a header file for a function you are using in your code.
Easiest way is to copy that function or method call and paste into Xcode quick search using shift+command+O. This will search all frameworks (and header files), find that function or method call and show you its location (the header in this case):
In this case, this call belongs to the Accelerate framework so on top of your file, enter:
#import <Accelerate/Accelerate.h>
When doing quick search, you might have to get rid of leading underscore. In other words, search for vImageBoxConvolve_ARGB8888
Hope this helps
Google is your friend: someone else fixed this by adding the Accelerate framework to their project (and this does look like a framework error).
https://github.com/rnystrom/RNBlurModalView/issues/5
Make sure you also have the QuartzCore framework included as well, as that is also required by that library.
Apparently vImageBoxConvolve_ARGB8888() is not defined. See if the Accelerate framework is properly included in the project.

Resources