xcode4 工作区中的两个项目(#import 失败)
我真的很难让它在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
您可以将引用的项目的标头或源文件夹添加到标头搜索路径。
您可以在苹果开发者论坛中找到有关此问题的更多信息。祝你好运。
You can add the header or source folder of your project you're referencing to your Header Search Paths.
You'll find more info about this problem in the apple developer forums. Best of luck.
你到底想做什么?
如果您有一个完整的 Xcode 项目,您打算在不同的产品之间共享,这通常建议您的项目构建一个或多个目标(例如框架等)。因此,您的“共享”项目应该能够自行构建框架,而不管它包含在哪个工作空间中,对吧?
我们假设它是一个框架。在大多数情况下,Xcode 可以通过简单地将框架产品添加到使用该框架的(假设的)应用程序的链接构建阶段来找出依赖关系。完毕。 Xcode 应该知道首先构建框架项目的目标,因为它在构建应用程序项目的目标时链接。
所以你的问题可能只是知道 Xcode 在哪里寻找文件。由于工作区中的项目共享该工作区的构建文件夹,因此它们都可以互相“看到”。但对于框架来说,通过文件名进行简单的导入并不能解决问题。您需要:
由于您要包含特定标头 (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:
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:
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.
这对我有用,
在构建设置中 --> 标题搜索路径 -->添加以下条目
$(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)