Duplicate Symbol Error: SBJsonParser.o?

好久不见. 提交于 2019-12-04 06:59:18

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 SBJson files from the .a files using ar. You should be able to do this using ar -t to list the objects in the .a and then ar -d to delete the ones that shouldn't be in there. You could of course also ar -x to extract all the .o files 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 :

  1. Go to Project B > Target > Build Phase > Remove JSON from the "Link Binary with libraries"
  2. Make sure the JSON framework is still in the project (don't remove it) so project B can build
  3. Build your project B you shouldn't get any error. The project should build but not embed the JSON frameworks symbols
  4. Add both project B product (a framework) AND JSON framework in project A
  5. 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
  6. Build your project A

Regards,

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!