xcode 何时勾选“将项目复制到目的地的组文件夹(如果需要)”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7760426/
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
When to tick "copy items into destination's group folder (if needed)"
提问by Matt Wilding
Whenever I am adding some files to my project by dragging and dropping in Xcode, a popup message is shown "Copy items into destination's group folder (if needed)".
每当我通过在 Xcode 中拖放来向我的项目添加一些文件时,都会显示一条弹出消息“将项目复制到目标的组文件夹(如果需要)”。
I noticed that when we are using most of the third party library's we DON'T tick the checkbox and instead specify the library path in "Header Search Path/Library search Path". But for smaller resource files like images, we tick the checkbox.
我注意到,当我们使用大多数第三方库时,我们不会勾选复选框,而是在“标题搜索路径/库搜索路径”中指定库路径。但是对于像图像这样的较小的资源文件,我们勾选复选框。
Which specific scenarios do I have to tick and what difference will it make?
我必须勾选哪些特定场景,它会有什么不同?
回答by Matt Wilding
It all depends on how you want to organize you project. It's far more common to store 3rd party frameworks somewhere on your machine that is independent of any project that may use that framework, thus allowing multiple projects to reference the same shared framework project from a standard directory. In that case, you don't want the 3rd party framework copied into your own project, and so you don't check that box.
这完全取决于您想如何组织您的项目。将 3rd 方框架存储在您的机器上的某个地方更为常见,该框架独立于可能使用该框架的任何项目,从而允许多个项目从标准目录引用相同的共享框架项目。在这种情况下,您不希望将第 3 方框架复制到您自己的项目中,因此您不要选中该框。
Images and other resource files are typically owned on a project-by-project basis, so it makes the most sense to store those in the directory of the project itself. To pull that off, you check that box to make sure a copy is made in the project's directory if one doesn't already exist.
图像和其他资源文件通常以项目为基础拥有,因此将它们存储在项目本身的目录中最有意义。要实现这一点,请选中该框以确保在项目目录中创建一个副本(如果尚不存在)。
Neither of those rules are absolute, you could copy an entire framework into your project's directory if you want, and you could reference media assets from some standard location. It's all up to you to implement good project organization.
这些规则都不是绝对的,如果需要,您可以将整个框架复制到项目目录中,并且您可以从某个标准位置引用媒体资产。实施良好的项目组织完全取决于您。
回答by Mundi
Typically, your project is saved to a project folder. If you drag stuff from outside the folder into your project without copying, only references to the added files are stored. You will have to be careful not to delete them, or your project will break.
通常,您的项目会保存到项目文件夹中。如果您将文件夹外部的内容拖入项目而不进行复制,则只会存储对添加文件的引用。您必须小心不要删除它们,否则您的项目将会中断。
Also, if you are using version control, such as the built-in git, files not in the main folder will not get added to your version tree.
此外,如果您使用版本控制,例如内置 git,则不在主文件夹中的文件将不会添加到您的版本树中。
I got into the habit of copying everything I need into the main folder and then drag-add without copying. This is working well for me and has so far avoided any errors.
我养成了将我需要的所有内容复制到主文件夹中的习惯,然后在不复制的情况下拖动添加。这对我来说效果很好,到目前为止已经避免了任何错误。