简体   繁体   English

如何从iOS中的现有框架创建静态库?

[英]How to create static library from an existing framework in iOS?

I have been provided with a framework by a third party vendor for an iPhone hardware accessory. 我已经为第三方供应商提供了一个用于iPhone硬件配件的框架。 So I have a folder like Device.framework. 所以我有一个像Device.framework这样的文件夹。 Inside that folder is a binary file and a set of .h files. 在该文件夹中是一个二进制文件和一组.h文件。 There are instructions for how to add this to an iOS project and use the classes contained within. 有关如何将其添加到iOS项目并使用其中包含的类的说明。 However, I'm actually using MonoTouch and want to use a static library. 但是,我实际上正在使用MonoTouch并且想要使用静态库。

Is there a way to create a static library that makes all the classes from the framework available in the static library? 有没有办法创建一个静态库,使静态库中的框架中的所有类都可用? So in my MonoTouch project I would link in the static library and have access to that framework. 因此,在我的MonoTouch项目中,我将链接到静态库并可以访问该框架。

A *.framework is simply a package containing: the static library, headers, associated meta data. A * .framework只是一个包,包含:静态库,标题,关联的元数据。 Copy and paste the .framework and extract the static *.a file and related header files. 复制并粘贴.framework并提取静态* .a文件和相关的头文件。

Then it's simply a matter of using the MonoTouch btouch tool to bind the static library for use in your MonoTouch project. 然后,只需使用MonoTouch btouch工具绑定静态库以便在MonoTouch项目中使用。 There is a great example of how to bind a native library to MonoTouch on Github. 有一个很好的例子,说明如何将本机库绑定到Github上的MonoTouch。 With guidance on targeting simulator + device and using the LinkWith attribute to embed the static library in a single *.dll: 有关定位模拟器+设备的指导,并使用LinkWith属性将静态库嵌入到单个* .dll中:

Also, make sure to check out the btouch Reference documentation here: 另外,请务必查看btouch参考文档:

Rename that binary file to Device.a . 将该二进制文件重命名为Device.a You can do that as the framework you mention is not done by Apple, hence it has to be a static library and not a dynamic one. 您可以这样做,因为您提到的框架不是由Apple完成的,因此它必须是静态库而不是动态库。

Make sure your project links that library ( Device.a ). 确保您的项目链接该库( Device.a )。

Include the headers in your project and reference them where appropriate. 在项目中包含标题并在适当的位置引用它们。

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

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