如何为iPhone构建静态库? [英] How do I build a static library for iPhone?

查看:172
本文介绍了如何为iPhone构建静态库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想要创建一个简单的静态库来运行。 iPhone设备,但我总是最后与XCode说,文件不是必需的架构,我试过了每一个建立标志,我发现没有运气。



我有它的工作模拟器建设它像这样:



$ gcc-4.2 -c StaticHelloWorld.c -o StaticHelloWorld.o
$ ar rcs libstatichelloworld.a StaticHelloWorld.o



但是如何构建设备?



$ b drisse

解决方案

在Xcode中,有一个名为Cocoa Touch Static Library的新项目模板。此模板提供了创建静态库所需的大多数设置。



有关iPhone静态库的示例,请参阅 Three20 Core Plot 项目。两者都为iPhone使用静态库。我们有一些有关如何在应用程序中加入库的说明主要Core Plot wiki。


I think that I've looked everywhere for an answer to my problem but without any luck.

I'm trying to create a simple static lib to run on the iPhone device but I keep ending up with XCode saying that "file is not of required architecture" and I've tried every build flag that I found without any luck.

I've got it to work on the emulator building it like this:

$gcc-4.2 -c StaticHelloWorld.c -o StaticHelloWorld.o
$ar rcs libstatichelloworld.a StaticHelloWorld.o

But how do I build it for device??

Regards, drisse

解决方案

Within Xcode, there is a New Project template called Cocoa Touch Static Library. This template provides most of the setup you need for creating a static library. You then just need to include your various source files, as well as your shared header file.

For an example of iPhone static libraries, see the Three20 and Core Plot projects. Both employ static libraries for the iPhone. We have some instructions on how to include the library within an application in the main Core Plot wiki.

这篇关于如何为iPhone构建静态库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆