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

时间:2023-01-03 13:29:03

I have been provided with a framework by a third party vendor for an iPhone hardware accessory. So I have a folder like Device.framework. Inside that folder is a binary file and a set of .h files. There are instructions for how to add this to an iOS project and use the classes contained within. However, I'm actually using MonoTouch and want to use a static library.

我已经为第三方供应商提供了一个iPhone硬件配件的框架。所以我有一个像Device.framework这样的文件夹。在该文件夹中是一个二进制文件和一组.h文件。有关如何将其添加到iOS项目并使用其中包含的类的说明。但是,我实际上正在使用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项目中,我将链接到静态库并可以访问该框架。

2 个解决方案

#1


13  

A *.framework is simply a package containing: the static library, headers, associated meta data. Copy and paste the .framework and extract the static *.a file and related header files.

A * .framework只是一个包,包含:静态库,标题,关联的元数据。复制并粘贴.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. There is a great example of how to bind a native library to MonoTouch on Github. With guidance on targeting simulator + device and using the LinkWith attribute to embed the static library in a single *.dll:

然后,只需使用MonoTouch btouch工具绑定静态库以便在MonoTouch项目中使用。有一个很好的例子,说明如何将本机库绑定到Github上的MonoTouch。有关定位模拟器+设备的指导,并使用LinkWith属性将静态库嵌入到单个* .dll中:

Also, make sure to check out the btouch Reference documentation here:

此外,请务必查看btouch参考文档:

#2


8  

Rename that binary file to 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.

将该二进制文件重命名为Device.a。您可以这样做,因为您提到的框架不是由Apple完成的,因此它必须是静态库而不是动态库。

Make sure your project links that library (Device.a).

确保您的项目链接该库(Device.a)。

Include the headers in your project and reference them where appropriate.

在项目中包含标题并在适当的位置引用它们。

#1


13  

A *.framework is simply a package containing: the static library, headers, associated meta data. Copy and paste the .framework and extract the static *.a file and related header files.

A * .framework只是一个包,包含:静态库,标题,关联的元数据。复制并粘贴.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. There is a great example of how to bind a native library to MonoTouch on Github. With guidance on targeting simulator + device and using the LinkWith attribute to embed the static library in a single *.dll:

然后,只需使用MonoTouch btouch工具绑定静态库以便在MonoTouch项目中使用。有一个很好的例子,说明如何将本机库绑定到Github上的MonoTouch。有关定位模拟器+设备的指导,并使用LinkWith属性将静态库嵌入到单个* .dll中:

Also, make sure to check out the btouch Reference documentation here:

此外,请务必查看btouch参考文档:

#2


8  

Rename that binary file to 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.

将该二进制文件重命名为Device.a。您可以这样做,因为您提到的框架不是由Apple完成的,因此它必须是静态库而不是动态库。

Make sure your project links that library (Device.a).

确保您的项目链接该库(Device.a)。

Include the headers in your project and reference them where appropriate.

在项目中包含标题并在适当的位置引用它们。