xcode 嵌入式二进制文件和链接框架有什么区别
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/32375687/
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
What is the difference between Embedded Binaries and Linked Frameworks
提问by Maxim Veksler
When using external framework Xcode now has an Embedded Binariesas well as Linked Frameworkssection.
当使用外部框架时,Xcode 现在有一个Embedded Binaries以及Linked Frameworks部分。
When you download an external framework and Finder->drag it into Xcode, it will place the framework into the Linked Frameworks and Librariessection.
当您下载外部框架并通过 Finder-> 将其拖入 Xcode 时,它会将框架放入Linked Frameworks and Libraries部分。
When you build a library with Carthage it recommends dragging into the Embedded Binariessection.
当您使用 Carthage 构建库时,建议将其拖入Embedded Binaries部分。
Both seem to be working in terms of linkage, as the API becomes available either way, further more when adding a framework into the Embedded Binariessection is it also automatically gets added into the Linked Frameworks and Librariessection.
两者似乎都在链接方面起作用,因为 API 以任何一种方式可用,而且在将框架添加到嵌入式二进制文件部分时,它也会自动添加到链接框架和库部分。
So, who is right? Carthage or the rest of the internet? and why are there 2 options for including external resources into Xcode projects?
那么,谁是对的?迦太基还是互联网的其他部分?为什么有 2 个选项可以将外部资源包含到 Xcode 项目中?
回答by Shripada
Linking- We must link a framework if we use any API defined in it.
Embedding - This process will ensure the added framework will be embedded within the App bundle, and potentially will help sharing code between the app, and any extension bundles. We embed only third party frameworks and not the ones provided by iOS as they are readily available in the device. If we are embedding, that means that, we will need to link to them too so that Xcode can compile and create the build. When the app runs in the device, then the embedded framework will be loaded into memory when needed.
链接 - 如果我们使用框架中定义的任何 API,我们必须链接框架。
嵌入 - 此过程将确保添加的框架将嵌入应用程序包中,并可能有助于在应用程序和任何扩展包之间共享代码。我们只嵌入第三方框架,而不嵌入 iOS 提供的框架,因为它们在设备中很容易获得。如果我们正在嵌入,这意味着我们也需要链接到它们,以便 Xcode 可以编译和创建构建。当应用程序在设备中运行时,嵌入式框架将在需要时加载到内存中。
回答by Basti
If you embed the binary it will be included into your product. If you only link a library or framework without embedding it, it will not be part of your product.
如果您嵌入二进制文件,它将包含在您的产品中。如果你只链接一个库或框架而不嵌入它,它就不会成为你产品的一部分。
However, in iOS8 all 3rd party frameworks need to be "embedded". Even a framework that is shared between various programs needs to be "embedded" into every single one of those programs. In the case where it was installed on the device in a shared location, any other installation process using the same "embedded" code from the shared location can re-use that existing installation. This is specific to iOS8, it has not been possible before iOS8 and outside the iOS world this answer would not be accurate.
但是,在 iOS8 中,所有 3rd 方框架都需要“嵌入”。即使是在各种程序之间共享的框架也需要“嵌入”到这些程序中的每一个中。如果它安装在共享位置的设备上,则使用来自共享位置的相同“嵌入”代码的任何其他安装过程都可以重新使用该现有安装。这是特定于 iOS8 的,在 iOS8 之前是不可能的,在 iOS 世界之外,这个答案是不准确的。
回答by yoAlex5
Linking
more about Linker
that works at compile time or load/run time. Linker
copya Library
into a target binary. Since Framework
is autonomous, the Linker
, in this case, is responsible for find and link the Dynamic Framework
inside the system loader pathor to find and link inside a bundle.
Linking
更多关于Linker
在编译时或加载/运行时工作的信息。Linker
将a复制Library
到目标二进制文件中。由于Framework
是自治的Linker
,在这种情况下,负责Dynamic Framework
在系统加载程序路径内部查找和链接或在包内部查找和链接。
Embedding
is a process of copying the binary into the target binary. As a result it will be located inside.
Embedding
是将二进制文件复制到目标二进制文件的过程。因此,它将位于内部。
Read more here
在这里阅读更多
回答by Lei Zhang
To my understand, the embedded binary only includes dynamic framework that is available on iOS 8 and above, otherwise you can only link the framework that is static.
据我了解,内嵌的二进制文件只包含在 iOS 8 及以上版本可用的动态框架,否则你只能链接静态的框架。