简体   繁体   English

将自定义框架链接到 xcode 中的库

[英]linking custom framework to library in xcode

I want to include Microblink's PDF417 framework into my library.我想将Microblink 的 PDF417框架包含到我的库中。 Library project compile and work fine but when I use MyLibrary.a file in my application I've got "undefined symbols for architecture armv7" error.库项目编译并正常工作,但是当我在我的应用程序中使用 MyLibrary.a 文件时,出现“架构 armv7 的未定义符号”错误。 Any ideas?有任何想法吗? Can I include custom framework to library or this isn't possible.我可以在库中包含自定义框架吗,或者这是不可能的。

Trojanfoe's answer is correct for your case. Trojanfoe 的回答对您的情况是正确的。 But in general, the answer depends on the type of the library inside the framework.但总的来说,答案取决于框架内库的类型。

iOS/MacOS framework is a just a collection of a library together with all relevant header files. iOS/MacOS 框架只是一个库和所有相关头文件的集合。 This makes including the library into other projects much easier, because the whole framework can be included at once, thus eliminating the need to modify linker and header search paths and linker flags.这使得将库包含到其他项目中变得更加容易,因为可以一次包含整个框架,从而无需修改链接器和头文件搜索路径以及链接器标志。

Library itself can be either a static library or a dynamic/shared library.库本身可以是静态库或动态/共享库。 Framework can contain the library of any type, there are no limitations in that regard.框架可以包含任何类型的库,在这方面没有限制。

If the library in framework is static, then all the objects from that library are copied into target product at compile time.如果框架中的库是静态的,则该库中的所有对象都会在编译时复制到目标产品中。 If the target product is a static library ( MyLibrary.a in your case), additional linking with the framework in the application is not needed, because all the objects are contained in MyLibrary.a如果目标产品是静态库(在您的情况下为MyLibrary.a ),则不需要与应用程序中的框架进行额外链接,因为所有对象都包含在MyLibrary.a 中

If the library in the framework is dynamic, then objects from that library are loaded at load-time or run-time, not at compile time.如果框架中的库是动态的,那么来自该库的对象在加载时或运行时加载,而不是在编译时加载。 Because of that, frameworks of that type need to be linked with end applications also.因此,该类型的框架也需要与最终应用程序链接。

In your case, pdf417 framework contains a dynamic library, which means you will also have to include that framework into your end application.在您的情况下,pdf417 框架包含一个动态库,这意味着您还必须将该框架包含到您的最终应用程序中。


I'm a developer on Microblink's PDF417 SDK .我是 Microblink 的PDF417 SDK的开发人员。 The thing is, we can provide our library in any format.问题是,我们可以提供任何格式的库。 The format we have chosen in our Github repository is an .embeddedframework which contains a dynamic library together with all resource files because that makes including the framework into Application projects very simple.我们在 Github 存储库中选择的格式是 .embeddedframework,它包含一个动态库和所有资源文件,因为这使得将框架包含到应用程序项目中非常简单。 If you have a use case which requires a different format, we invite you to contact us on https://help.microblink.com/hc/en-us如果您有需要不同格式的用例,我们邀请您通过https://help.microblink.com/hc/en-us与我们联系

A static library is just a collection of object files (a bit like a zip file without compression or hierarchy) and cannot hold information about any dependencies it might have.静态库只是目标文件的集合(有点像没有压缩或层次结构的 zip 文件)并且不能保存有关它可能具有的任何依赖项的信息。

Therefore you have to link the final executable binary against both your library and the dependent framework.因此,您必须将最终的可执行二进制文件与您的库和相关框架链接起来。 The same applies if the dependency was a static library, dynamic library or framework.如果依赖项是静态库、动态库或框架,则同样适用。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM