什么是 Xcode 中的嵌入式二进制文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/30173529/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 18:07:17  来源:igfitidea点击:

What are Embedded Binaries in Xcode?

xcodexcode6embedalamofire

提问by Doug Richardson

I'm using Alamofirein a Swift project, and part of their manual installation instructions are to add Alamofire under Embedded Binariesin the General tab for my application target.

我在 Swift 项目中使用Alamofire,他们的部分手动安装说明是在我的应用程序目标的常规选项卡中的嵌入式二进制文件下添加 Alamofire 。

enter image description here

在此处输入图片说明

What are Embedded Binaries?

什么是嵌入式二进制文件

采纳答案by Mark Szymczyk

Embedded binaries are binary files that are copied to your application bundle when you build the project. Use embedded binaries when your application relies on third-party frameworks so people can use your application without needing those frameworks installed on their machine. Embedded binaries keep users from having to manually install third-party frameworks. Your application uses the framework you embedded.

嵌入式二进制文件是在您构建项目时复制到您的应用程序包的二进制文件。当您的应用程序依赖第三方框架时使用嵌入式二进制文件,这样人们就可以使用您的应用程序,而无需在他们的机器上安装这些框架。嵌入式二进制文件使用户不必手动安装第三方框架。您的应用程序使用您嵌入的框架。

In your Alamofire example your application relies on Alamofire. If you didn't embed the Alamofire framework, nobody would be able to use your application unless they installed Alamofire manually. By embedding Alamofire with your application everyone can run your application.

在您的 Alamofire 示例中,您的应用程序依赖于 Alamofire。如果您没有嵌入 Alamofire 框架,那么除非手动安装 Alamofire,否则没有人能够使用您的应用程序。通过在您的应用程序中嵌入 Alamofire,每个人都可以运行您的应用程序。

回答by matt

  • "Binary" means: compiled code — as opposed to "source code", which is what you are working with when you write code as text.

    They couldhave given you source code and let youcompile it, but they didn't; they are keeping the source code secret, so they've given it all to you aftercompilation, so that you can't read it.

  • "Embedded" means: to be included inside your app bundle, by copying them into it at build time.

    So, they are handing you some compiled code (frameworks) and telling you how to include them inside your app bundle. These frameworks, unlike Cocoa's frameworks, do not already exist on the device, so if you don't include them inside the app, they won't be present and your app would be unable to call into them.

    Contrast this to Cocoa's frameworks. They, too, are compiled code. But they doalready exist on the device. Therefore they are not embedded inside your app; they are merely linked(and, if they appeared, would appear in the next group, Linked Frameworks and Libraries).

  • “二进制”的意思是:编译后的代码——与“源代码”相对,后者是您将代码编写为文本时所使用的。

    他们本可以给你源代码并让编译它,但他们没有;他们对源代码保密,所以他们编译都给了你,你看不到。

  • “嵌入”意味着:通过在构建时将它们复制到应用程序包中来包含在应用程序包中。

    所以,他们会交给你一些编译后的代码(框架)并告诉你如何将它们包含在你的应用程序包中。这些框架与 Cocoa 的框架不同,设备上尚不存在,因此如果您不将它们包含在应用程序中,它们将不存在并且您的应用程序将无法调用它们。

    将此与 Cocoa 的框架进行对比。它们也是编译代码。但它们确实已经存在于设备上。因此,它们不会嵌入您的应用程序中;它们只是链接(如果它们出现,将出现在下一组,链接框架和库中)。

回答by Shubham Mishra

Embedding binaries copies the entire framework to the target.

嵌入二进制文件会将整个框架复制到目标。

A frameworkis a hierarchical directory that encapsulates a dynamic library, header files, and resources, such as storyboards, image files, and localized strings, into a single package. Apps using frameworks need to embed the frameworkin the app's bundle.

Aframework是一个分层目录,它将动态库、头文件和资源(例如故事板、图像文件和本地化字符串)封装到单个包中。使用框架embed the framework的应用程序需要在应用程序包中。

So, when you embed a framework in your app, it increases the size of your app because it is copied to you app bundle. In most of the scenarios we will be using this sections when we are using third party framework.

因此,当您在应用程序中嵌入框架时,它会增加应用程序的大小,因为它会被复制到您的应用程序包中。在大多数情况下,当我们使用第三方框架时,我们将使用此部分。

When we add a frameworkto Embedded Binariesit automatically adds that framework to Linked Frameworks and Librariesalso.

当我们frameworkEmbedded Binaries它添加 a 时,它Linked Frameworks and Libraries也会自动添加该框架。

Refer to apple documentation for more details: https://developer.apple.com/library/archive/technotes/tn2435/_index.html

更多详情请参考苹果文档:https: //developer.apple.com/library/archive/technotes/tn2435/_index.html