Xcode 4:如何将静态库目标依赖项添加到项目中

发布于 2024-11-06 22:09:45 字数 677 浏览 0 评论 0原文

我知道,这个问题已经被问过几次了,但主要是针对 Xcode 3.x。对于 iPad,我有两个项目都位于一个公共工作区

  • Foo(一个基于视图的应用程序)和
  • Foolib(一个静态 Cocoa-Touch 库)中,

前者依赖于后者。我似乎无法弄清楚如何添加该依赖项。文档中没有很好地解释,所以我尝试了以下操作:

  1. 单击左侧导航区域中的 Foo 项目,
  2. 选择顶部的构建阶段并展开目标依赖项部分
  3. 单击加号按钮,但结果列表为空。

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

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

我想知道 Xcode 如何发现这些依赖关系。苹果是说我根本不需要添加这个目标依赖项吗?但是 Xcode 如何发现其中一个正在使用另一个呢?

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

如果能朝正确的方向推动,我们将不胜感激。谢谢。

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, a view-based application and
  • Foolib, a static Cocoa-Touch library

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. Click on the Foo project in the Navigation Area on the left,
  2. Select Build Phases up the top and expand the Target Dependencies section
  3. Click the plus button, but the resulting list is empty.

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

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.

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?

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

擦肩而过的背影 2024-11-13 22:09:45

一般来说,Xcode 4 似乎会自动发现依赖关系,正如编辑方案表所暗示的那样。其他开发人员提到,依赖项不会自动发现,需要显式列出它们:

因此,编辑方案 ->构建->从您的工作区添加目标。

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

请参阅:此链接

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:

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

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.

See: this link

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文