iOS 静态与动态框架说明 [英] iOS Static vs Dynamic frameworks clarifications

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

问题描述

我不得不承认,随着 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 文件)分发,也可以分发标头.我知道这是处理这种情况的常用方法,但我想找到比这更简单的方法(如果可能的话,还可以捆绑一些资源).
  • 我还发现 iOS 7 不支持动态 .framework 库(仅静态),因为它不支持动态链接.但 iOS 8 和静态链接一样.

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

And here are my questions regarding this information:

  • 我看到我可以通过将 Mach-O 类型更改为静态库"来创建一个 .framework 目标并将其设为静态.这样就足以支持 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 文件夹中.过去我曾经运送我的库作为静态框架和捆绑包......

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

但是,如果您使用 Swift,上述选项将不适合您.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.

如果要快速使用,您必须使用动态框架.理论上,动态框架在 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 静态与动态框架说明的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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