Xcode 9: Linking a static framework against another static framework

生来就可爱ヽ(ⅴ<●) 提交于 2021-01-27 07:59:56

问题


In the spirit of Xcode 9's "revolutionary" feature, namely compiling static frameworks, we are trying to make our subprojects build as static frameworks, so they can be linked statically against the main application target.

One of our sub-projects has a static framework dependency itself (Firebase). When we build the sub-project as a dynamic framework, everything works fine, but once we switch it to mach-o staticlib, suddenly, it loses the Firebase library symbols.

Here is the output of nm for building our subproject as a dynamic vs static framework, respectively:

dynamic:

00000000001c3450 S _OBJC_CLASS_$_FIRApp

static:

                 U _OBJC_CLASS_$_FIRApp

The problem is, both cases the framework builds "successfully", but complains about missing symbols once it is linked against another target (test target for example). How do we make sure all symbols from Firebase frameworks are embedded into out sub-project when it itself is a static framework? We tried -all_load, -ObjC linker flags without avail...


回答1:


Disclaimer: Still searching for the final answer.

After using static frameworks more, I now realize they don't get automagically merged by the linker, same way they get merged into an executable/dynamic target.

I end up linking all static frameworks, and their sub-dependencies, against the main target anyway.

There should be a way to merge static frameworks, without making the final framework a dynamic lib, alas, the search continues...



来源:https://stackoverflow.com/questions/47470534/xcode-9-linking-a-static-framework-against-another-static-framework

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