I currently have ShareKit in my project that is compiled as a static library. It is properly implemented. I also have implemented Amazon's AWS SDK by just adding their framework into my project.
It seems that the duplicate symbol is coming from Amazon's AWS SDK file, "AWSIOSSDK". This is what it looks like:
And that file is colliding with ShareKit's file, libShareKit.a. This is what that file looks like:
Anyway both of these files are ones that I haven't seen before. And it seems that some JSON files are colliding within them.
I have looked at other SO questions and they say to do some things with the compiled sources but none of these files are in the compiled sources from either library.
Here is the exact error Xcode gives:
ld: duplicate symbol _OBJC_CLASS_$_SBJsonParser
Anyway, does anyone have any ideas what I should do? My app does not compile unless I fix this issue.
Thanks!
Both of these have built SBJsonParser into their static libraries. This is not the correct way to build a static library. Each should build without SBJson and then you should link all of them together with SBJson. There are a couple of solutions:
- Rebuild these libraries (or have their maintainers do so) to not include third-party libraries directly into a static library. This is the ideal solution.
- Remove the incorrect
SBJsonfiles from the.afiles usingar. You should be able to do this usingar -tto list the objects in the.aand thenar -dto delete the ones that shouldn't be in there. You could of course alsoar -xto extract all the.ofiles and link them directly.
You could go ahead and split a library archive into its object files and merge them again by leaving out the duplicates.
See the following walkthrough for getting an idea to manage that task: Avoiding duplicate symbol errors during linking by removing classes from static libraries
I had the same issue with FaceBookConnect Framework (let's call it project B) and my project (project A). Both were linking again JSON framework.
The solution is :
- Go to Project B > Target > Build Phase > Remove JSON from the "Link Binary with libraries"
- Make sure the JSON framework is still in the project (don't remove it) so project B can build
- Build your project B you shouldn't get any error. The project should build but not embed the JSON frameworks symbols
- Add both project B product (a framework) AND JSON framework in project A
- Go to Project A > Target > Build Phase and check that both project B and JSON have been added to the "Link binary with libraries" section
- Build your project A
Regards,
来源:https://stackoverflow.com/questions/11603551/duplicate-symbol-error-sbjsonparser-o