Xcode 4和嵌套项目 - 找不到头文件 [英] Xcode 4 and nested projects -- header files not found

查看:185
本文介绍了Xcode 4和嵌套项目 - 找不到头文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有很多问题的Xcode 4和嵌套项目,在Xcode 3.2下工作得很好。这是一个非常基本的,我不能解决:

I'm having a myriad of problems with Xcode 4 and nested projects that worked just well under Xcode 3.2. Here's a very basic one I cannot solve:

我正在构建一个可可框架,需要另一个可可框架,我有源。所以我执行通常的步骤:

I'm building a cocoa framework that requires another cocoa framework for which I have the source. So I perform the usual steps:


  • 拖动所需的 .xcodeproj 文件框架到我的主框架项目

  • 在我的主框架中TARGETS> MyFramework> Build Phases> Target Dependencies :添加嵌套项目的目标

  • 确保嵌套框架的头文件是公开的

  • 在Xcode设置>位置> 构建位置将建立产品放置在衍生数据位置(推荐)

  • 建立产品路径设置为 $ {BUILT_PRODUCTS_DIR } (或发布)位置

  • 两个目标的体系结构设置完全相同 li>
  • Drag the .xcodeproj file of the required framework into my main framework project
  • In my main framework under TARGETS > MyFramework > Build Phases > Target Dependencies: Add the nested project's target
  • Make sure the header files of the nested framework are public
  • In Xcode Settings > Locations > Build Location I have it set to Place build products in derived data location (recommended)
  • Build products path of both targets are set to ${BUILT_PRODUCTS_DIR} and tell me they are at the DerivedData/Debug (or Release) location
  • Architecture settings for both targets are identical

然后我点击[CMD] + B来构建它,它告诉我,它没有找到嵌套框架的头文件。当我检查设置时,用户标题搜索路径包含 DerivedData / Debug 的路径,里面有嵌套框架目标,头文件位于 A / Headers

Then I hit [CMD] + B to build and it tells me that it doesn't find the header files of the nested framework. When I check the settings, User Header Search Paths contain the path to DerivedData/Debug, and inside there is the nested framework target with the header files in Versions/A/Headers.

我坐在这里,任何人都知道我做错了什么?

I'm sitting here, anybody an idea what I'm doing wrong?

当我将用户标题搜索路径更改为<$ c $时,建立调试 c> $ {BUILT_PRODUCTS_DIR} /MyFramework.framework/Headers 。但是,当构建分发时,此方法不起作用,因为框架会使用发布设置,并将其设置在不同的子目录中...

The issue goes away when building for Debug when I change the User header search paths to ${BUILT_PRODUCTS_DIR}/MyFramework.framework/Headers. However this doesn't work when building for Distribution as the frameworks then use their Release settings, which ends up in a different subdirectory...

我的临时解决方案是为嵌套项目定义 Distribution 配置。

My temporary solution is to also define a Distribution configuration for the nested projects. This way the headers are found and the linker can link successfully.

推荐答案

到目前为止,我的综合知识:

Here's my synthesized knowledge so far:

使用Xcode删除整个 public 标题,它是一个PITA,在归档应用程序时无法正常工作。

Forget the whole public header thing with Xcode, it's a PITA and doesn't work correctly when archiving your app. Instead, have all static library header files on the project level and tell your app where to find it.


  1. 通过确保所有目标都具有构建配置的相同名称(即向静态库添加AdHoc和部署配置),来减轻您的痛苦。

  1. Ease your pain by making sure all targets have the same name for the build configuration (i.e. add an "AdHoc" and "Deployment" configuration to the static libraries).

在构建设置中,指向标题搜索路径(如果您使用 #include< file.h> )或用户标题搜索路径(如果您使用 #includefile.h)到静态库项目的目录。如果静态库项目是在您的应用程序目录中,请使用:

In build settings, point the Header Search Paths (if you use #include <file.h>) or User Header Search Paths (if you use #include "file.h") to the directory of the static library project. If the static library project is inside your app directory, use this:

$(PROJECT_DIR) code>(递归启用)

如果您有一个目录包含静态库项目和b)那么这应该工作:

If you have a directory which contains a) the static library project and b) your app, then this should work:

$(PROJECT_DIR)/ ..递归 enabled)

"$(PROJECT_DIR)/.." (recursive enabled)

如果子模块包含已编译的库,请将库搜索路径设置为:

If the submodule contains compiled libraries, set your Library Search Paths to:

$(TARGET_BUILD_DIR)

您使用的专案跳过安装设为

没有公共头文件(构建阶段»复制标题)在任何静态库,否则Xcode将无法归档应用程序。

Again, no public header files (Build Phases » Copy Headers) in any of the static libraries, otherwise Xcode will not be able to archive an app.

确保告诉Xcode何时构建静态库,如下所示:此技术文档从苹果

Make sure to tell Xcode when to build the static libraries, as shown in this Tech Doc from Apple.






旧答案:


Old Answer:

我还没有找到一个真正的解决方案静态库的这个问题。对我有用的是:

I still haven't found a real solution to this problem with static libraries. What works for me is:


  • 为静态库创建AdHoc配置

  • 添加 $(BUILT_PRODUCTS_DIR)到应用程序的用户标题搜索路径(已选中递归) - >这在运行应用程序时使用

  • 在Xcode菜单中,选择产品> 构建> 构建归档

  • Create an "AdHoc" Configuration for the static library
  • Add $(BUILT_PRODUCTS_DIR) to User Header Search paths for the application (with recursive checked) -> this is used when running the app
  • In the Xcode menu, select Product > Build For > Build For Archiving

这样,应用程序找到头文件和构建本身,它最终在DerivedData // Build / Products / AdHoc-iphoneos /中作为应用程序包。 这些简单说明(死链接)来自TestFlightApp.com我可以打包这个应用程序到一个IPA,并发送它。只要从Xcode中选择存档应用程序,即使它们确实在AdHoc-iphoneos构建目录中,仍然找不到标头。

This works, the app finds the header files and builds itself, it ends up in DerivedData//Build/Products/AdHoc-iphoneos/ as an App bundle. Following these simple instructions (dead link) from TestFlightApp.com I can pack this App into an IPA and send it around. Simply selecting to Archive the app from Xcode does again not find the headers, even if they truly are in the AdHoc-iphoneos build directory.

这篇关于Xcode 4和嵌套项目 - 找不到头文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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