xcode4 工作区中的两个项目(#import 失败)

发布于 2024-10-21 09:24:04 字数 374 浏览 3 评论 0原文

我真的很难让它在 xcode 4 中工作。

我有一个项目将在许多应用程序(网络)中重用,所以我创建一个工作区并添加我的两个项目。到目前为止,一切都很好.... 这就是它失败的地方..

#import "JSONRequest.h"

没有明显的原因。它自动完成头文件的文件名。我认为这与“方案”(xcode 4 中的新功能)有关,因此我尝试在构建阶段添加我的网络目标。更改它们的顺序...在管理方案下设置“共享”..我尝试了很多不同的设置组合,但没有成功..得到的错误消息是:

JSONRequest.h: No such file or directory

如果您有线索,请告诉我。

I'm really struggling to get this to work in xcode 4.

I have one project that I will reuse in many applications (networking) so I create a workspace and add my two projects. So far so good....
This is where it fails..

#import "JSONRequest.h"

For no apparent reason. It auto completes the file name of the header file. I thought this had something to do with the "scheme" (also new in xcode 4) so I've tried to add my networking target in the build phase. Changing order of them... set "Shared" under Manage schemes.. I've tried so many different combinations of the settings without any success.. And the error message is get is:

JSONRequest.h: No such file or directory

If you have a clue, please let me know.

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

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

发布评论

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

评论(3

無心 2024-10-28 09:24:04

您可以将引用的项目的标头或源文件夹添加到标头搜索路径。

  1. 单击正在导入 JSONRequest.h 的目标。
  2. 单击构建设置。
  3. 在搜索框中输入“标题搜索路径”。
  4. 双击值单元格。
  5. 单击+号。
  6. 设置您所引用的项目的路径。假设它名为 JSONlib。该路径相对于引用项目(使用 JSONlib 的项目)的根。例如:../JSONlib/src/headers/ 或 .h 文件所在的任何位置。
  7. 单击完成。
  8. 清理然后构建。

您可以在苹果开发者论坛中找到有关此问题的更多信息。祝你好运。

You can add the header or source folder of your project you're referencing to your Header Search Paths.

  1. Click on the target that's importing JSONRequest.h.
  2. Click on Build Settings.
  3. Enter "Header Search Paths" into the search box.
  4. Double click on the value cell.
  5. Click the + sign.
  6. Set the path to the project you're referring. Let's say it's called JSONlib. The path is relative to the root of the referring project (the project that's using JSONlib). For example: ../JSONlib/src/headers/ or wherever it is that the .h file lives.
  7. Click done.
  8. Clean and then build.

You'll find more info about this problem in the apple developer forums. Best of luck.

江南月 2024-10-28 09:24:04

你到底想做什么?

如果您有一个完整的 Xcode 项目,您打算在不同的产品之间共享,这通常建议您的项目构建一个或多个目标(例如框架等)。因此,您的“共享”项目应该能够自行构建框架,而不管它包含在哪个工作空间中,对吧?

我们假设它是一个框架。在大多数情况下,Xcode 可以通过简单地将框架产品添加到使用该框架的(假设的)应用程序的链接构建阶段来找出依赖关系。完毕。 Xcode 应该知道首先构建框架项目的目标,因为它在构建应用程序项目的目标时链接。

所以你的问题可能只是知道 Xcode 在哪里寻找文件。由于工作区中的项目共享该工作区的构建文件夹,因此它们都可以互相“看到”。但对于框架来说,通过文件名进行简单的导入并不能解决问题。您需要:

#import <MyNetworkingFramework/MyNetworkingFramework.h>

由于您要包含特定标头 (JSONRequest.h)(它必须是框架目标的复制标头构建阶段中的公共标头之一),因此您需要:

#import <MyNetworkingFramework/JSONRequest.h>

如果您的“共享”项目不是框架,您需要修改您的问题以包括对您的两个项目及其目标的更全面的描述。

What are you really trying to do?

If you have an entire Xcode project you intend to share between different products that usually suggests your project builds one or more targets (such as a framework, etc.). Therefore, your "shared" project should be able to build the framework on its own, irrespective of the workspace it's contained in, right?

Let's assume it's a framework. In most cases, Xcode can figure out the dependency by simply adding the framework product to the Link build phase of the (assumed) app using the framework. Done. Xcode should know to build the framework project's target first, since it's linked against when building the app project's target.

So your problem is likely just a matter of knowing where Xcode is looking to find files. Since projects within workspaces share that workspace's build folder, they can all "see" each other. But in the case of a framework, A simple import by file name won't cut it. You'd need:

#import <MyNetworkingFramework/MyNetworkingFramework.h>

Since you're including a specific header (JSONRequest.h) (which must be one of the public headers in the framework target's copy headers build phase), you'd need:

#import <MyNetworkingFramework/JSONRequest.h>

If your "shared" project is not a framework, you'll need to amend your question to include a more thorough description of your two projects and their targets.

漫雪独思 2024-10-28 09:24:04

这对我有用,

在构建设置中 --> 标题搜索路径 -->添加以下条目

$(SRCROOT) 并将其标记为递归。

如果上述方法不起作用,您也可以尝试以下方式,

并将其标记为递归。

希望这对您有帮助! (您可能需要清理或重新启动工作区)

This worked for me,

In build settings --> Header Search Path --> Add below entry

$(SRCROOT) and mark it as recursive.

If above not worked you can also try following way,

<path-of-other-project> and mark it as recursive.

Hope this helps to you ! (You may require to clean or restart the workspace)

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