在iPhone中实现静态库 [英] Implementing Static Libraries In iPhone

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

问题描述

我在之后创建了一个静态库这个链接

但是我在使用库时遇到了问题。关于如何在iPhone项目中使用静态库的参考我遵循此链接

But I am facing Problems in using the library. For reference on how to use static libraries in an iPhone project I followed this link .

但我仍然在努力解决如何在任何其他iPhone项目中实现静态库?问题。

But I am stil struggling with the "How to implement static libraries in any other iPhone project?" question.

谢谢大家。

推荐答案

你可以用十字架-project如在帖子中引用,但这有几个下滑。

You can use cross-project referencing as in the posts but this has several downturns.

我使用这个设置一般适用于Xcode(不仅适用于iPhone)并增加了编译时间静态库版本控制。

I use this setup that works on Xcode in general (not only for the iPhone) and adds compile-time static library version control.

我将静态库放在〜/ Library / MyLibraries /中,.a存档及其公共头文件。这样你可以有不同的版本:

I put my static libraries in ~/Library/MyLibraries/, the .a archive along with their public headers. This way you can have different versions of them:

~/Library/MyLibraries/
                     /MyLib-1.0.0/Headers/header1.h
                                         /header2.h
                                 /libmylib.a
                                 /libmylib_debug.a
                     /MyOtherLib-2.1.0/Headers/...
                                      /libmyotherlib.a

然后在Xcode设置中添加用户变量:

Then in Xcode settings add the user variables:

LIBRARIES_DIR      $(USER_LIBRARY_DIR)/MyLibraries
MYLIBRARY_LIBROOT  $(LIBRARIES_DIR)/MyLib-1.0.0

并修改设置

HEADER_SEARCH_PATHS $(MYLIBRARY_LIBROOT)/Headers
OTHER_LDFLAGS       $(MYLIBRARY_LIBROOT)/libmylib.a

现在更改MYLIBRARY_LIBROOT以选择您的图书馆版。更多关于我的博客文章

Now change MYLIBRARY_LIBROOT to choose your library version. More on this blog post by me.

如果你想保持简单,那么只需编译库并设置HEADER_SEARCH_PATHS和OTHER_LDFLAGS。

If you want to keep it simple then just compile the library and setup HEADER_SEARCH_PATHS and OTHER_LDFLAGS.

这篇关于在iPhone中实现静态库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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