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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/9370518/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-30 16:55:42  来源:igfitidea点击:

Xcode 4.2 how include one project into another one?

iosversion-controlxcode4.2

提问by Alex Stone

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.

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

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.

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

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.

拜托,有人可以向我逐步解释我需要做什么才能将一个 XCode 项目添加到另一个项目中吗?我见过很多像“标题搜索路径”这样的衬垫,但这并不能告诉我太多。

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.

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

Thank you!

谢谢!

回答by MobileOverlord

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 notopen in XCode.

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

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

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

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.

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

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_loadand -ObjC

有时您需要添加一些其他链接器标志。在 Build Settings 中搜索 Other Linker Flags 并添加-all_load-ObjC

Other Linker Flags

其他链接器标志

Hope this helps, I know the first time I tried to do this I was banging my head against the wall for a while.

希望这会有所帮助,我知道我第一次尝试这样做时,我的头撞在墙上了一段时间。

回答by JiaYow

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

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

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

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

Is that what you mean?

你是这个意思吗?

回答by JP Illanes

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

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

回答by Sandy D.

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.

确保选择“创建组”而不是“创建文件夹引用”。如果您的文件夹是蓝色而不是黄色,那么您就有了文件夹参考。文件夹应该是黄色的。

回答by Snehal Tanawade

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.

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

回答by yoAlex5

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

您有两个变体可以将源代码添加到您的项目中:

  1. Explicit dependency[About]via creating target dependencywith a cross-project reference[About]
  2. Implicit dependency[About]if the source code is a part of the same Workspace[About]
  1. Explicit dependency[关于]通过target dependency使用[关于]创建cross-project reference
  2. Implicit dependency[关于]如果源代码是相同的Workspace[关于] 的一部分