xcode 将二进制文件与库 VS Embed Frameworks 链接起来
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/27015154/
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
Link Binary with libraries VS Embed Frameworks
提问by Alberto Schiariti
What's the difference in the build phases between putting a framework in "Link binary with libraries" or in "Embed frameworks"?
将框架放入“Link binary with libraries”或“Embed frameworks”在构建阶段有什么区别?
采纳答案by Jakub Truhlá?
Link binary with librariesLink frameworks and libraries with your project's object files to produce a binary file. You can link a target's source files against libraries in the target's active SDK or against external libraries.
将二进制文件与库链接 将框架和库与项目的目标文件链接以生成二进制文件。您可以将目标的源文件链接到目标的活动 SDK 中的库或外部库。
Embed FrameworksYou can create an embedded framework to share code between your app extension and its containing app.
嵌入框架您可以创建一个嵌入框架,以在您的应用程序扩展与其包含的应用程序之间共享代码。
-
——
Timeline(Look at this sentence)- "If your containing app target linksto an embedded framework, it must include the arm64 architecture or it will be rejected by the App Store."
时间轴(看这句话)-“如果你的包含应用程序目标链接到一个嵌入式框架,它必须包含 arm64 架构,否则它将被 App Store 拒绝。”
回答by ff10
I have been looking at some answers here and there and would like to amend this learning if somebody comes across this question again.
我一直在这里和那里寻找一些答案,如果有人再次遇到这个问题,我想修改这个学习。
In any case, if we want to use any of a frameworks resources (i.e. the API), we need to link to it. In that case we need to add it in the "Linked Frameworks and Libraries" section in the bottom of the General Target Settings.
在任何情况下,如果我们想使用任何框架资源(即 API),我们都需要链接到它。在这种情况下,我们需要将它添加到 General Target Settings 底部的“Linked Frameworks and Libraries”部分。
If we embed a library we are shipping the library – as it is – with our app bundle. This could be handy e.g. on machines running macOS who certainly do not have a specific 3rd party library.
如果我们嵌入了一个库,那么我们就是在随我们的应用程序包一起发送库。这可能很方便,例如在运行 macOS 的机器上当然没有特定的 3rd 方库。
So, what about iOS? There is no possibility to install 3rd party libraries on an iOS device per se – plus Apple is very strict regarding fat frameworks (libraries built for multiple platforms). So there has to be a way for the libraries to be delivered anyway? Since just linking them is not enough for the user of our application what other possibilities do we have?
那么,iOS呢?不可能在 iOS 设备上安装 3rd 方库本身——而且 Apple 对胖框架(为多个平台构建的库)非常严格。那么无论如何必须有一种方法可以交付图书馆?既然仅仅链接它们对于我们应用程序的用户来说是不够的,我们还有什么其他可能性?
That's where a peculiar build phase comes into play. In the project settings under Build Phases there's the link binary with libraries section. This steps strips the unnecessary parts from the fat frameworks and leaves the necessary parts with the bundle so that it is able to run on a device that is agnostic about the app's dependencies.
这就是一个特殊的构建阶段发挥作用的地方。在 Build Phases 下的项目设置中有带有库部分的链接二进制文件。此步骤从胖框架中去除了不必要的部分,并将必要的部分留在包中,以便它能够在不知道应用程序依赖项的设备上运行。
回答by yoAlex5
For an apptarget
对于应用程序目标
Static Library
-Link
Static Framework
-Link
Dynamic Framework
-Embed
Static Library
——Link
Static Framework
——Link
Dynamic Framework
——Embed