Xcode 9:将一个静态框架链接到另一个静态框架 [英] Xcode 9: Linking a static framework against another static framework

查看:36
本文介绍了Xcode 9:将一个静态框架链接到另一个静态框架的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

本着 Xcode 9 的革命性"功能的精神,即编译静态框架,我们试图将我们的子项目构建为静态框架,以便它们可以静态链接到主应用程序目标.

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.

我们的一个子项目本身具有静态框架依赖项 (Firebase).当我们将子项目构建为动态框架时,一切正常,但是一旦我们将其切换为 mach-o staticlib,它突然丢失了 Firebase 库符号.

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.

以下是 nm 的输出,分别用于将我们的子项目构建为动态框架和静态框架:

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

动态:

00000000001c3450 S _OBJC_CLASS_$_FIRApp

静态:

                 U _OBJC_CLASS_$_FIRApp

问题是,在这两种情况下,框架都成功"构建,但是一旦链接到另一个目标(例如测试目标),就会抱怨缺少符号.当 Firebase 框架本身是一个静态框架时,我们如何确保将来自 Firebase 框架的所有符号嵌入到子项目中?我们尝试了 -all_load-ObjC 链接器标志但无济于事...

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...

推荐答案

免责声明:仍在寻找最终答案.

更多地使用静态框架后,我现在意识到它们不会被链接器自动合并,就像它们被合并到可执行/动态目标一样.

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...

这篇关于Xcode 9:将一个静态框架链接到另一个静态框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆