iOS Static vs Dynamic框架说明 [英] iOS Static vs Dynamic frameworks clarifications

查看:161
本文介绍了iOS Static vs Dynamic框架说明的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不得不承认,随着iOS 8的发布,我对iOS中的动态和静态框架感到有些困惑。

I have to admit that with the release of iOS 8 I am a bit confused about dynamic and static frameworks in iOS.

我正在寻找一种分发方式我创建的库,我需要支持iOS 7及更高版本。 (注意:这将是一个专有框架。我不能使用可可豆荚,我也不能分发来源)。以下是我已经知道的事情:

I am looking for a way to distribute a library that I created, and I need to support iOS 7 and above. (Note: This will be a proprietary framework. I cannot use cocoa pods, and I also cannot distribute the source). Here is what I already know:


  • iOS 8为iOS引入了嵌入式框架,但据我了解,它们不适用于iOS 7,仅适用于iOS 8及更高版本。

  • 我可以选择将我的库作为静态库(.a文件)分发,也可以分发标题。我知道这是处理这种情况的常用方法,但我想找到一些比这更简单的东西(如果可能的话,还要用它捆绑一些资源)。

  • I还发现iOS 7不支持动态.framework库(仅静态),因为它不支持动态链接。但iOS 8和静态链接一样。

以下是关于此信息的问题:

And here are my questions regarding this information:


  • 我看到我可以创建一个.framework目标,并通过将Mach-O类型更改为静态库使其成为静态。这样就足够了没有任何问题支持iOS 7,并将我的库作为.framework包分发?如果是这样,为什么iOS 8中的嵌入式框架是一个很大的交易,因为互联网上的许多资源都在暗示?我错过了什么?

  • 是否有必要对.framework进行编码,就像我对其他任何应用程序一样?

  • 如果我需要包含其他资源怎么办? (如核心数据或图像)和我的.framework文件?我需要为它制作一个单独的.bundle文件吗?

推荐答案

在iOS8之前,Xcode只允许为iOS创建静态库。常见的问题是我们必须发布二进制和标题分开。

Before iOS8, Xcode only allowed the option of creating static libraries for iOS. The common problem with that was we had to ship the binary and headers separately.

后来,一些开发人员提出了创建静态框架的想法。 [.framework只是一个带有符号链接到lib和标题的文件夹]。一个这样的例子是 https://github.com/jverkoey/iOS-Framework

Later, some developers came with the idea of creating 'static frameworks'. [the .framework is just a folder with symbolic links to the lib and the headers]. One such example is https://github.com/jverkoey/iOS-Framework

此选项适用于iOS 7或8或之前。因为它们只是静态库,便于捆绑头文件。

This option will work for iOS 7 or 8 or before that. Because they are just static libraries with the convenience of bundling the headers files along.

至于你对资源的问题,我们需要将它们捆绑在'.bundle'中。为了运送它们,我不确定我们是否可以将它们包含在.framework文件夹..过去我曾经把我的libs作为静态框架和捆绑包...

As for your questions of the resources, we would need to bundle them in '.bundle'.. For shipping them i am not sure if we can enclose them in the .framework folder.. In the past i used to ship my libs as a static framework and bundle...

但是如果你使用上述选项将不适合你迅速。 Xcode不支持构建包含swift代码的静态库。

However the above option will not work for you if you use Swift. Xcode does not support building static libraries that include swift code.

如果有快速使用,你必须使用Dynamic框架。从理论上讲,动态框架可以在iOS7中运行。但是,我认为如果应用程序针对iOS7并使用动态框架,iTunes Connect会拒绝: - )。

You must go with Dynamic frameworks if there is swift usage. In theory, Dynamic frameworks work in iOS7.. But, i think iTunes Connect will reject if the app is targeting iOS7 and uses Dynamic frameworks :-).

希望这有助于

这篇关于iOS Static vs Dynamic框架说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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