在XCode 4中将静态库链接到iOS项目 [英] Linking a static library to an iOS project in XCode 4

查看:90
本文介绍了在XCode 4中将静态库链接到iOS项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个编译为静态库的项目( AQGridView ),但我似乎无法将其添加到我的项目中。

I have a project (AQGridView) that compiles to a static library, but I can't seem to add it to my project.

将项目拖到我的项目中会创建一个工作区,如果我尝试从 libAQGridView.a 文件> DerivedData 目录,它不会将其识别为库。我不确定我做错了什么。

Dragging in the project to my project creates a workspace, and if I try to link the libAQGridView.a file from the DerivedData directory it doesn't recognize it as a library. I'm not sure what I'm doing wrong.

这是 AQGridView 项目。有没有人具体知道如何在XCode 4项目中使用它?

This is the AQGridView project. Does anyone know specifically how to use it in an XCode 4 project?

推荐答案

我这样做如下:


  1. 在静态库项目中拖动。如果您在Xcode中打开静态库项目,请立即关闭它。

  2. 在项目导航器中选择主项目(我正在添加静态库的项目)和编辑器中,在左栏中的标题TARGETS下,选择我的主项目目标并导航到Build Phases选项卡。

  3. 单击目标依赖项的+并添加库图标目标来自添加的静态库项目的依赖项。

  4. 单击链接二进制文件的+和库,并添加工作区文件夹下的库图标。

  5. 如果标题在静态库项目本身中的链接方式,可能还需要输入静态库项目标题的标题搜索路径。

  1. Drag in the static library project. If you have the static library project open in Xcode, close it now.
  2. Select the main project in the project navigator (the project I'm adding the static library to) and in the editor, under the header TARGETS in the left-hand column, select my main project's target and navigate to the Build Phases tab.
  3. Click the "+" for Target Dependencies and add the library icon target dependency from the added static library project.
  4. Click the "+" for Link Binary with Libraries and add the library icon that is under the folder "Workspace".
  5. It may also be necessary to enter a Header Search Path for the headers of the static library project if that is how the headers are linked in the static library project itself.

如果您没有看到静态库项目嵌套在主项目的项目导航器中的主项目下,最可能的原因是静态库自己的Xcode项目仍然是开放的。退出Xcode并打开其中包含嵌套静态库项目的主项目,而无需打开原始静态库项目本身,您应该看到它在主项目中显示为嵌套项目。

If you don't see the static library project as nested under the main project in the main project's project navigator, the most likely reason for that is that the static library's own Xcode project is still open. Quit Xcode and open up the main project that has the nested static library project in it without opening up the original static library project itself, and you should see it appearing as a nested project in your main project.

这篇关于在XCode 4中将静态库链接到iOS项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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