我已经创建了两个 iOS .frameworks
I have created two iOS .frameworks
它们都完美编译
我的结构如下:
iPadProject
- framework1
- framework2
所以Framework2包含在framework1中,framework1包含在实际的iPad项目中
So Framework2 is included in framework1 and framework1 is included in the actual iPad Project
所以我的问题是,如果我将 framework1 和 framework2 添加到我的 iPadProject 中,它将无法编译,因为它抱怨来自 framework2 的重复符号(这是合乎逻辑的,因为它已经包含在 framework1 中)
So my problem is, if I add both framework1 and framework2 into my iPadProject it won't compile because its whining about duplicate symbols from framework2 ( that's logical because it was already included in framework1)
但是,如果我只在我的 iPadProject 中包含 framework1,当我从 framework1 访问一个方法时,他又从 framework2 访问一个方法,它会使用signal SIGABRT"使应用程序崩溃
But if i only include framework1 into my iPadProject when i access a method from framework1 that in his turn access a method from framework2 it crashes the application with "signal SIGABRT"
问题是因为它现在是嵌套的,所以链接器将 f2 链接到 f1 -- 但只有 f2 中 f1 需要的部分.
the problem is that because it is nested right now, the linker links f2 into f1 -- BUT only the parts of f2 that are needed by f1.
喜欢
f2 有 5 个符号 (f2_1 - 5)
f1 使用 f2_1 和 f2_2 但不是 3,4,5
=> 链接器将其丢弃
f2 has 5 symbols (f2_1 - 5)
f1 uses f2_1 and f2_2 but NOT 3,4,5
=> the linker throws it away
现在应用需要 f2_3、f2_4 和 f2_5,但它们不存在……但在编译时没有人知道.
now the app needs f2_3, f2_4 and f2_5 but they aren't there... but nobody knows that at compile time.
现在您尝试通过再次将应用程序与 f2 链接来解决它,但和以前一样,在编译时没有人优化链接器 f2_3 - 5 并且假定它们在 f1 中,因此是重复的!
now you try to resolve it by linking the app with f2 again but as before nobody at compile time the linker optimized out f2_3 - 5 and they are assumed to be in f1 and so are duplicates!
已经提到的解决这个 Rob Napier 的方法.不要嵌套框架(主要不是静态框架/第三部分)
the way to solve this Rob Napier already mentioned. Don't nest Frameworks (mainly not static ones / 3rd part ones)
解决方法是在 f1 链接到 f2 时将 -all_load 传递给链接器!
a workaround is to pass -all_load to the linker when f1 links in f2!
这篇关于具有依赖项的 iOS 框架的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!