添加到项目的文件夹的 Xcode 设置说明

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/8851144/
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-09-14 22:59:19  来源:igfitidea点击:

Explanation of Xcode settings for folders added to project

xcodedirectory

提问by Ankit Srivastava

What is the difference between "Create groups for any added folders" and "Create folder references for any added folders"?

“为任何添加的文件夹创建组”和“为任何添加的文件夹创建文件夹引用”之间有什么区别?

I have been doing this for quite some time now, but to be honest I don't know what's the difference between the two.

我已经这样做了很长一段时间了,但说实话,我不知道两者之间有什么区别。

回答by Philippe Sabourin

Groups are only within your project and are for organization purposes only. They do not reflect what is on the file system nor where the files will be compiled into in the app.

组仅在您的项目中并且仅用于组织目的。它们不反映文件系统上的内容,也不反映文件将在应用程序中编译到的位置。

Folders are basically like including a folder on the file system, where if you move a file within a folder reference, it will be reflected in your project as well. These folders are also reflected inside your app bundle when its compiled.

文件夹基本上就像在文件系统上包含一个文件夹,如果您在文件夹引用中移动文件,它也会反映在您的项目中。这些文件夹在编译时也会反映在您的应用程序包中。

I usually use groups. For example, on the file system I have all my classes in a /Classes folder but have them separated in my project into groups, such as View Controllers, Custom Views, Data Model, etc. These don't really need to be separate in the file system but its nice to have in the project.

我通常使用组。例如,在文件系统上,我的所有类都在 /Classes 文件夹中,但在我的项目中将它们分成了多个组,例如视图控制器、自定义视图、数据模型等。这些实际上不需要在文件系统,但它很高兴在项目中使用。

Sometimes I'll use folder references if it's important for the organization be maintained once it goes to the app bundle, but that is pretty rare. Also, when including files from a third party library that could be updated often, you can use a folder reference so you don't have to remember to add files when they are added to the library.

有时我会使用文件夹引用,如果它对组织进入应用程序包后维护很重要,但这种情况很少见。此外,当包含来自可能经常更新的第三方库的文件时,您可以使用文件夹引用,这样您就不必在将文件添加到库时记住添加文件。

回答by rckoenes

When you create folders in your project the folders are also present in you apps bundle. Groups are ignored and all files in the groups are added to the apps bundle root.

当您在项目中创建文件夹时,这些文件夹也会出现在您的应用程序包中。组被忽略,组中的所有文件都被添加到应用程序包根目录中。

回答by vampirewalk

If you have a lot of images or audio files,you might want organize these files well, separate them in different folder instead of placing all of them in app root.

如果您有很多图片或音频文件,您可能需要很好地组织这些文件,将它们分开放在不同的文件夹中,而不是将它们全部放在应用程序根目录中。

Another situation, you have a project using UIWebView to load local html in your app.You may not want to mess up html, javascript, and css file.

另一种情况,您有一个项目使用 UIWebView 在您的应用程序中加载本地 html。您可能不想弄乱 html、javascript 和 css 文件。

So, maybe organize these file hierarchically would be a good solution.

因此,也许按层次组织这些文件将是一个很好的解决方案。