ios use multiple third party framework - ios

I Use Two third party framework.
SIPPhone (SIPphone.framework)
RealtimeVideo (H264Play.a,netsdk.a)
These framework work fine on single project.
Than I these framework added to one project
First App SIPPhone is work fine ,
but Enter RealtimeVideo page .APP will crash.
So I try to Build->Setting "other linker flags".
Added to -ObjC , -force_load,... etc.
Xcode have display errors. 223 duplicate symbols for architecture i386.
Ex:
duplicate symbol _ff_inverse in:
/Users/sonas/Desktop/jackyfile/CCTVtest/SIPLib.framework/PortSIPLib(PortSIPLib)
/Users/sonas/Desktop/jackyfile/CCTVtest/CCTVtest/H264Play.a(mathtables.o)
Please , give me some advice. thanks.

This issues of duplicate symbol for architecture i386 has been discussed in a different stack overflow section. Sharing the link for your reference.
6 duplicate symbols for architecture i386

Related

Google Services - Duplicate symbols on link

I'm getting the google services for ios integrated in my app. For reasons outside my control I can't use cocoapods, so I'm following the manual approach outlined here.
The problem is the Play Games C++ SDK Version 2.1 (gpg.framework). When I add it, (build phases, link binary with libraries, +) and build I get a lot of duplicate symbol errors:
duplicate symbol _AES_decrypt in:
../../../../../Monkey/modules/googleservices/native/gpg-cpp-sdk/ios/gpg.framework/gpg(libgpg.a-arm64-master.o)
../../../../../Monkey/modules/googleservices/native/gpg-cpp-sdk/ios/gpg.framework/gpg(aes.o)
. . .
duplicate symbol __ZTVN4buzz10XmlBuilderE in:
../../../../../Monkey/modules/googleservices/native/gpg-cpp-sdk/ios/gpg.framework/gpg(libgpg.a-arm64-master.o)
../../../../../Monkey/modules/googleservices/native/gpg-cpp-sdk/ios/gpg.framework/gpg(xmlbuilder.o)
ld: 7242 duplicate symbols for architecture arm64 clang: error: linker
command failed with exit code 1 (use -v to see invocation)
I've spent a day going over the common causes for duplicate symbols in stack overflow and nothing seems to work. Removed all google frameworks and re-added them, added the google frameworks in a different project (same issue), cleared out derived data, etc..
Any ideas on what might be causing it? Help much appreciated, thanks.
Specs:
Xcode 7.2.1
Deployment Target: 7.0
Play Games C++ SDK Version 2.1
This might not be the best solution, but I solved it by opening up the gpg file, and removing the offending .o files that contained duplicate symbols.
Followed the instructions here.
The files I removed are libgpg.a-* and example_mul.o
Can't guarantee it all works, but at least it's letting me do a google services sign-in at this point.

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

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

RubyMotion - Duplicate symbols when linking?

I've added a 3rd party library (Tesseract) to a project. The library builds and runs with no errors when used in an XCode project. My RubyMotion project builds, but fails when linking:
duplicate symbol _main in:
vendor/Tesseract/build-iPhoneSimulator/libTesseract.a(svpaint.o)
./build/iPhoneSimulator-5.0-Development/objs/main.o
duplicate symbol _selCopy in:
vendor/Tesseract/build-iPhoneSimulator/libTesseract.a(sel1.o)
/Library/RubyMotion/data/5.0/iPhoneSimulator/libmacruby-static.a(id.o)
duplicate symbol _selWrite in:
vendor/Tesseract/build-iPhoneSimulator/libTesseract.a(sel1.o)
/Library/RubyMotion/data/5.0/iPhoneSimulator/libmacruby-static.a(id.o)
ld: 3 duplicate symbols for architecture i386
I've tried adding Tesseract two different ways, as a :static library and as an :xcode project. Same error both ways.
Given that I'm able to build and run a normal Xcode project which uses this library, I'm pretty sure I'm doing something wrong with RubyMotion.
I solved this issue by building Tesseract with the --disable-graphics option for configure, as mentioned in their FAQ.

Resources