Prefix Static Library iOS

拟墨画扇 提交于 2019-11-29 21:56:16

The only safe solution (other than not doing this at all) is to build any dependencies with a prefix on all symbols.

The easiest method of prefixing is the classic "find-and-replace". This is error-prone, so it's a good idea to hit the .a with nm -a and scour the results for any non-prefixed symbols.

A second, much safer method is to use a two-pass compilation process.

  • The first pass builds the dependent project and runs nm to dump all symbols into a header file.
  • The second pass builds the dependent project again, but this time with the generated prefix header file imported in the precompiled header. This prefix header must be used anywhere you reference symbols from the dependency in your framework in order to properly refer to the renamed symbols.

For reference, we use this with Nimbus to generate the Nimbus prefix headers: https://github.com/jverkoey/nimbus/blob/master/scripts/generate_namespace_header

This allows you to distribute a .framework with a prefixed version of Nimbus embedded.

You can now link the resulting .a into your framework and safely avoid any linker conflicts when a third party developer inevitably links their own version of the dependency into their project.

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