How to get past this duplicate symbol error (Vungle, CodePush)? - ios

How do I get past this error?
duplicate symbol _zipOpen4 in:
/Users/a/app/app-client/ios/Pods/VungleSDK-iOS/VungleSDK.embeddedframework/VungleSDK.framework/VungleSDK(vungle_zip.o)
/Users/a/Library/Developer/Xcode/DerivedData/AppClient-hirdjpuiiuosayehatqakfrifyvs/Build/Products/Debug-iphoneos/libCodePush.a(zip.o)
ld: 1 duplicate symbol for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

The duplicate symbol is fairly generic and co-relates to many things. In this case
There could be three reasons. Vungle and CodePush might be using same constant names. Or Vungle may internally be using CodePush or vice-versa.
Try to include only one in them and see if it works. Chances are that you might be using both libraries in same interface/implementation if so try splitting code into multiple files.

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.

Duplicate symbol _OBJC_CLASS_$_Base64

I am trying to add mobile.connect.framework to the existing project. Before adding the framework, The application is building and running properly. But, as soon as I am adding the framework, it is giving the Duplicate symbol OBJC_CLASS$_Base64 error. I went through numerous posts like Duplicate Symbol OBJC_CLASS$_LoginController
and How duplicate symbol problem arises. But was unable to find the solution.
Please help me how to resolve this one. It has already consumed my half a day.
Error :-
ld: warning: directory not found for option '-L/Users/shailendra.suriyal/Documents/MyProjects/..../UberNewUser/ExternalLib/CardIO' duplicate symbol _OBJC_CLASS_$_Base64 in: /Users/shailendra.suriyal/Library/Developer/Xcode/DerivedData/./Build/Intermediates/Muri.build/Debug-iphonesimulator/Muri.build/Objects-normal/x86_64/Base64.o /Users/shailendra.suriyal/Documents/MyProjects/..../UberNewUser/ExternalLib/FrameWork/mobile.connect.framework/mobile.connect duplicate symbol _OBJC_METACLASS_$_Base64 in: /Users/shailendra.suriyal/Library/Developer/Xcode/DerivedData/hadqxhhslzvmwfddwlthosrdljjy/Build/Intermediates/.../Debug-iphonesimulator/Muri.build/Objects-normal/x86_64/Base64.o /Users/shailendra.suriyal/Documents/MyProjects/.../UberNewUser/ExternalLib/FrameWork/mobile.connect.framework/mobile.connect ld: 2 duplicate symbols for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
Finally, I got it. I just removed the Base64.h from the compiled resources under Build Phases.
You seem to be linking both the source and the library for the Base64 class.
This line...
/Users/shailendra.suriyal/Library/Developer/Xcode/DerivedData/Muri-hadqxhhslzvmwfddwlthosrdljjy/Build/Intermediates/Muri.build/Debug-iphonesimulator/Muri.build/Objects-normal/x86_64/Base64.o
...says you've compiled the class directly.
This one...
/Users/shailendra.suriyal/Documents/MyProjects/taxi_ios_client/UberNewUser/ExternalLib/FrameWork/mobile.connect.framework/mobile.connect
...says you're linking it from inside the mobile.connect.framework binary.
If you're using it from the library, you should remove the source from your project.
(If you've already removed the source and you're still getting this, delete the derived data and try again.)
DUPLICATE FILE CREATES OF "LoginController"

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

Conflicting libraries in iOS project

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

Error: duplicate symbols for architecture armv7 after change Core Data Model

I have an app using core data framework. I was working fine. I just changed the data model - add an attribute to one entity.
And when I try to build it, I got an error:
duplicate symbol _OBJC_METACLASS_$_AccountFolder in:
/Users/XXX/Library/Developer/Xcode/DerivedData/MyApp-bxsswgxdenxgjweotkkkckaoalat/Build/Intermediates/MyApp.build/Debug-iphoneos/MyApp.build/Objects-normal/armv7/AccountFolder-33D7EA63E98D6090.o
ld: 4 duplicate symbols for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I did some search, and most people getting this error is from mistyping .h to .m, or import same .h several times. I checked my code. I don't have that.
And the coredata framework is still there.
Does anyone know what else can be the reason?
Thanks.
Check if there are multiple NSManagedObject subclass files generated after making this change. There should be duplicate files generated after your attribute change. Check in finder window as well as in project and then remove the duplicate files. That should fix this issue.

Resources