Xcode 4.2 如何将一个项目包含到另一个项目中?

发布于 2025-01-07 16:09:58 字数 385 浏览 0 评论 0原文

我一直在搜索,但找不到关于如何将一个 XCode 项目及其所有子类包含到另一个项目中的清晰而简单的解释。我经常在我的示例项目中看到类似的内容从网上下载,但自己不知道该怎么做。

在 XCode 中,除了 .h 和 .m 文件以及文件夹之外,还有一个全新的项目,以蓝色的 xcode 项目图标开头,可扩展以包含项目中的所有内容。

请问,有人可以向我解释一下,我需要做什么才能将一个 XCode 项目添加到另一个项目中吗?我见过很多诸如“标头搜索路径”之类的行,但这并不能告诉我太多信息。

更新:重新阅读文档后,我意识到要包含的项目必须拖动到父项目的蓝色项目图标上。常规源可以拖动到任何地方,但项目必须拖动到一个项目。

谢谢你!

I keep searching, but cannot find a clear and simple explanation on how to include one XCode project, along with all of it's sub-classes into another project. I routinely see stuff like that in sample projects that I download off the web, but do not know how to do this myself.

Within XCode, along with .h and .m files, and folders, there's a whole new project, starting with a blue xcode project icon, that is expandable to contain everything within the project.

Please, can someone explain to me step by step what do I need to do to add one XCode project into another one? I've seen a ton of one liners like "header search paths", but that does not tell me much.

UPDATE: After re-reading the documentation, I realized that the project to include must be dragged ONTO the BLUE project icon of the parent project. Regular sources can be dragged anywhere, but a project must be dragged onto a project.

Thank you!

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

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

发布评论

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

评论(6

吾性傲以野 2025-01-14 16:09:59

您只需将任何 xcode 项目文件 (*.xcodeproj) 拖放到所需父项目的项目导航窗格中即可。

然后,您可能需要根据您的需要添加目标依赖项。

你是这个意思吗?

You can just drag-and-drop any xcode-project file (*.xcodeproj) into the project navigation pane of your desired parent-project.

You then may need to add target dependencies, depending on your needs.

Is that what you mean?

嘴硬脾气大 2025-01-14 16:09:59

确保选择“创建组”而不是“创建文件夹引用”。如果您的文件夹是蓝色而不是黄色,则您有一个文件夹引用。该文件夹应该是黄色的。

Make sure to choose "create groups" instead of "create folder references". If your folder is blue instead of yellow, then you have a folder reference. The folder should be yellow.

素罗衫 2025-01-14 16:09:59

从 Finder 中将 xcode 文件拖放到另一个 xcode 文件中。
它会要求您复制文件,然后选中复选框,它将复制到您的项目。

drag and drop xcode file to another xcode file from finder.
It will ask you for copy the file then check the check box and it will copy to your project.

£烟消云散 2025-01-14 16:09:59

您可以通过两种方式将源代码添加到项目中:

  1. 显式依赖项[关于] 通过使用跨项目引用创建目标依赖[关于]
  2. 隐式依赖[关于] 如果源代码是相同的一部分工作区[关于]

You have two variants to add source code into your project:

  1. Explicit dependency[About] via creating target dependency with a cross-project reference[About]
  2. Implicit dependency[About] if the source code is a part of the same Workspace[About]
独守阴晴ぅ圆缺 2025-01-14 16:09:58

当您尝试向 Xcode 项目添加静态库时,这很有意义。为此需要执行几个步骤。首先,确保静态库项目在 XCode 中打开。

然后首先将静态库 xcodeproj 文件(从 Finder)拖放到应用程序的 xcode 项目中。
StaticLib

此后,您需要将此库添加到应用程序的构建阶段。单击主项目,然后选择目标的 BuildPhases 选项卡。

Build Phases

您需要将其他项目添加到“目标依赖项”和“链接二进制文件与库”部分。

最后,应用程序需要了解您的标头。因此,您需要将静态库类的路径添加到用户标头搜索路径中。转到主目标的构建设置并搜索标头搜索路径。

标题搜索路径

这将使您的应用程序了解新的静态库。

有时您需要添加一些其他链接器标志。在“构建设置”中搜索“其他链接器标志”并添加 -all_load-ObjC

其他链接器标志

This makes a lot of sense when you are trying to add a static library to your xcode projects. There are a couple steps required for doing this. First, make sure that the static library project is not open in XCode.

Then start by dragging and dropping the static library xcodeproj file (from the Finder) onto your app's xcode project.
StaticLib

After this you need to add this library to your app's build phases. Click on the main project, and select the BuildPhases tab of the target.

Build Phases

You're going to want to add the other project to the Target Dependencies and to your Link Binary With Libraries Section.

Finally, the app needs to be aware of your headers. Therefore, you need to add the path to your static libraries classes to your User Header Search Paths. Go to the Build Settings of the Main Target and search for Header Search Path.

Header Search Path

This will make your app aware of the new static library.

Sometimes you need to add a few Other Linker Flags. In the Build Settings search for Other Linker Flags and add -all_load and -ObjC

Other Linker Flags

土豪 2025-01-14 16:09:58

在添加或删除项目之前,请确保要添加为子项目的项目未打开。

Make sure the project you want to add as subproject it's not open, before you add it or drop it.

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