简体   繁体   English

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

[英]Xcode 4.2 how include one project into another one?

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. 我一直在搜索,但是找不到关于如何将一个XCode项目及其所有子类都包含到另一个项目中的清晰简单的解释。 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. 在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? 拜托,有人可以一步一步向我解释将一个XCode项目添加到另一个XCode项目中需要做什么吗? 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. 更新:重新阅读文档后,我意识到要包含的项目必须拖到父项目的BLUE项目图标上。 Regular sources can be dragged anywhere, but a project must be dragged onto a project. 常规源可以拖到任何地方,但是必须将项目拖到项目上。

Thank you! 谢谢!

This makes a lot of sense when you are trying to add a static library to your xcode projects. 当您尝试向xcode项目中添加静态库时,这很有意义。 There are a couple steps required for doing this. 为此,需要执行几个步骤。 First, make sure that the static library project is not open in XCode. 首先,请确保静态库项目在XCode中打开。

Then start by dragging and dropping the static library xcodeproj file (from the Finder) onto your app's xcode project. 然后,首先将静态库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选项卡。

建造阶段

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. 转到主要目标的构建设置,然后搜索标题搜索路径。

标头搜索路径

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 在生成设置搜索其它链接器标记并添加-all_load-ObjC

其他链接器标志

Hope this helps, I know the first time I tried to do this I was banging my head against the wall for a while. 希望这会有所帮助,我知道我第一次尝试这样做是将我的头撞在墙上了一段时间。

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

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? 你是这个意思吗?

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. 该文件夹应为黄色。

drag and drop xcode file to another xcode file from finder. 将xcode文件从finder拖放到另一个xcode文件。 It will ask you for copy the file then check the check box and it will copy to your project. 它将要求您复制文件,然后选中复选框,它将复制到您的项目。

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] Explicit dependency [关于]通过创建target dependencycross-project reference [公司]
  2. Implicit dependency [About] if the source code is a part of the same Workspace [About] Implicit dependency [About],如果源代码是同一Workspace的一部分[About]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM