Xcode4工作区共享项目

发布于 2024-10-25 17:36:14 字数 230 浏览 6 评论 0原文

我正在尝试使用新的 Xcode4 工作区功能来迁移一些之间具有依赖关系的 Xcode3 项目。我有一个创建静态库的项目,然后是一个依赖于静态库的应用程序项目。因此,正如指南中提到的,我创建了一个新的工作区并将这两个项目拖到工作区中。但是,当我构建应用程序时,它无法从静态库中找到头文件。我收到“没有这样的文件或目录”错误。我的目的是让 Xcode 自动检测依赖项。但是,不确定我做错了什么,我无法让它工作。 非常感谢任何帮助。那里也没有太多文档。

I am trying to use the new Xcode4 workspace feature to migrate some Xcode3 projects that has dependencies between them. I have a project which creates a static library and then an application project which depends on the static library. So, as the guide mentioned, I created a new workspace and dragged both the projects into the workspace. However, when I build my application, it's unable to find the header files from my static library. I get "No such file or directory" error. My intention is to let Xcode auto detect the dependencies. But, not sure what I am doing wrong, I couldn't get it to work.
Any help is greatly appreciated. There isn't much documentation out there either.

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

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

发布评论

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

评论(3

平安喜乐 2024-11-01 17:36:14

经过几个令人沮丧的小时后,我可能找到了解决方案(仍然不确定这是否是正确的方法)。

  1. 创建了一个新工作区
  2. 添加了共享库项目
  3. 在共享库下面(不在内部)添加了应用程序项目
  4. 共享库的打开构建阶段,并确保在复制标头时将其分组到
  5. 应用程序的公共打开构建设置中以及在输入的标头搜索路径中“BUILD_PRODUCTS_DIR”\usr\local\include
  6. 在目标的构建阶段,包含静态库(共享库)的链接

进行了清理和构建,一切都已成功构建。

然而,我仍然不相信这是正确的方法,因为根据 Xcode4 指南,不需要更改设置,只需将项目添加到工作区即可解决所有问题。有一天,我希望找到正确的解决方案并使用它。

谢谢
贾维德

After few frustrating hours, I may have found a solution (still not sure if it's the right way).

  1. Created a new workspace
  2. Added the shared library project
  3. Added the application project below shared library (not inside)
  4. Open Build Phase of shared library and made sure when copying headers it is grouped to public
  5. Open Build settings of application and in the Header Search Paths typed in "BUILD_PRODUCTS_DIR"\usr\local\include
  6. And in Build Phase of target, included a link to static library (shared library)

Did a clean and build and everything was built successfully.

However, I am still not convinced this is the right way, as according to Xcode4 guide, no changes to settings is necessary, just adding projects to workspace will take care of everything. Someday, I hope to find the correct solution and use it.

Thanks
Javid

不爱素颜 2024-11-01 17:36:14

至少有几种方法可以解决这个问题。

我所做的是为主目标的用户标头搜索路径构建设置设置一个值,指向库路径。只需在构建设置编辑器搜索框中输入“用户标题”即可找到它。

如果您正在使用打算经常使用的库,最好为其设置源代码树设置。这是在 XCode Prefs -> 中源树。添加一个条目,放入库源的路径,并为其指定一个合理的设置名称,例如。 XXLIBRARY_SOURCE。然后在用户标头搜索路径(或需要库路径的任何其他构建设置)中,可以使用 $(XXLIBRARY_SOURCE) 作为路径。

一个更简单但不太灵活的替代方案是将库的标头拖到您的主项目中。

There are at least a couple of ways to go about this.

What I do is set a value for the User Header Search Path build setting for the main target, pointed to the library path. Just type 'user header' in the build settings editor search box and you'll find it.

If you're consuming a library that you intend to use often, it's best to set up a source tree setting for it. This is in XCode Prefs -> Source Trees. Add an entry, put in the path to the library source, and give it a sensible Setting Name, eg. XXLIBRARY_SOURCE. Then in the user header search path (or any other build setting where you need the library path), you can use $(XXLIBRARY_SOURCE) as the path.

A simpler but less flexible alternative is just to drag the library's headers into your main project.

醉态萌生 2024-11-01 17:36:14

问题似乎在于 Xcode 环境变量报告了错误的位置。例如 $(TARGET_BUILD_DIR) 转换为:

/build/Debug/

..但是使用工作区时,会在该路径中插入额外的文件夹:

/build/products/Debug

。 .Xcode 似乎忽略或无法处理。

The issue seems to lie with the Xcode environment variables reporting the wrong location. For instance $(TARGET_BUILD_DIR) translates to:

/build/Debug/

..but when using workspaces an extra folder is inserted into that path:

/build/products/Debug

..which Xcode seems to ignore or can't handle.

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