Xcode 4:如何将静态库目标依赖项添加到项目 [英] Xcode 4: How to Add Static Library Target Dependency to Project

查看:448
本文介绍了Xcode 4:如何将静态库目标依赖项添加到项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道,这已经被问过几次了,但是大多数是Xcode3.x。对于iPad,我有两个项目都生活在同一个工作区中

I know, this has been asked a few times, but mostly for Xcode 3.x. For the iPad, I have two projects both living in a common workspace


  • 基于视图的应用程序Foo和

  • Foolib,一个静态的Cocoa-Touch库

前者取决于后者。我似乎无法解决如何添加该依赖项。在文档中对此解释不充分,因此我尝试了以下操作:

the former depending on the latter. I seem unable to work out how to add that dependency. It's not well explained in the documentation, so I tried the following:


  1. 在左侧导航区域中单击Foo项目,

  2. 在顶部选择构建阶段并展开目标依赖项部分

  3. 单击加号按钮,但结果列表为空。

我也尝试将.a文件拖放到该部分中,但收效甚微。此外,文档还指出

I have also tried to drag/drop the .a file into that section, with little success. Also, the documentation states


如果工作空间中一个项目的构建产品依赖于工作空间中另一个项目的构建产品(例如,如果一个项目建立了另一个项目使用的库,则Xcode会发现这种隐式依赖关系,并以正确的顺序进行构建。

If the build product of one project in a workspace is dependent on the build product of another project in the workspace (for example, if one project builds a library used by the other project), Xcode discovers such implicit dependencies and builds in the correct sequence.

我想知道Xcode如何发现那些依赖关系。苹果是否在说我根本不需要添加此目标依赖项?但是然后Xcode怎么发现一个正在使用另一个?

I wonder how Xcode discovers those dependencies. Is Apple saying I don't have to add this target dependency at all? But then how would Xcode discover that one is using the other?

最后但并非最不重要的一点,我将需要以某种方式将.h文件从Foolib传递到Foo。建议这样做的方法是什么?显然,我不想复制它们。有了框架,头文件就包括在内了,但是人们在使用他们自己并行开发的静态库时通常会做什么。

Last but not least, I will need to get the .h files from Foolib across to Foo somehow. What is the recommended way of doing that? Obviously, I don't want to just copy them. With frameworks the header files come included, but what do people generally do when working with static libraries that they themselves develop in parallel.

朝着正确的方向轻描淡写会很多赞赏。谢谢。

A nudge in the right direction would be much appreciated. Thank you.

推荐答案

通常,Xcode 4似乎会自动发现依赖项,正如编辑方案表所暗示的那样。其他开发人员已经提到,不会自动发现依赖项,而是需要明确列出它们:

In general Xcode 4 seems to discover the dependencies automatically as the Edit Scheme sheet implies. Other developers have mentioned that the dependencies are not automatically discovered and require explicitly listing them:

因此,Edit Scheme-> Build->从工作区添加目标。

So, Edit Scheme -> Build -> add targets from your workspace.

就静态库头文件而言,Xcode 4似乎存在问题,至少在代码完成和语法高亮方面。我可以使它们与静态库中的类一起正常工作的唯一方法是,将有关头文件的副本拖到主项目中的组文件夹中的某个位置。请注意,您应该取消选中添加到目标...,这将注意语法突出显示和代码完成。其余的应通过为其提供适当的标题搜索路径来进行处理。那将是用户标题搜索路径= $(BUILT_PRODUCTS_DIR)-取决于您如何设置位置首选项。

As far as the static library header files go, Xcode 4 seems to have a problem, at least with code completion and syntax highlighting. The only way I can get either to work properly with classes in static libraries to to drag a copy of the header files in question to a location into a group folder in the main project. Note that you should uncheck Add to Target... That takes care of the syntax highlighting and code completion. The rest should be handled by giving it the proper header search path. That would be User Header Search Paths = $(BUILT_PRODUCTS_DIR) - depending on how you set up your locations preferences.

请参阅:此链接

这篇关于Xcode 4:如何将静态库目标依赖项添加到项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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