Xcode 中文件夹和组的区别?

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

Difference between folder and group in Xcode?

xcode

提问by hinterbu

In Xcode, what is the difference between a folder and a group? Are these interchangeable terms or is there a subtle?difference?

在 Xcode 中,文件夹和组有什么区别?这些术语是可互换的还是有细微的区别?

采纳答案by Rashwan L

Groups

团体

With groups, Xcode stores in the project a reference to each individual file.

对于组,Xcode 在项目中存储对每个单独文件的引用。

Folders

文件夹

Folder references are simpler. You can spot a folder reference because it shows up in blue instead of yellow.

文件夹引用更简单。您可以发现文件夹引用,因为它显示为蓝色而不是黄色。

There are two types of folders in Xcode: groups and folder references. You can use groups to organize files in your project without affecting their structure on the actual file system. This is great for code, because you're only going to be working with your code in Xcode. On the other hand, groups aren't very good for resource files.

On any reasonably complicated project, you'll usually be dealing with dozens – if not hundreds – of asset files, and those assets will need to be modified and manipulated from outside of Xcode, either by you or a designer. Putting all of your resource files in one flat folder is a recipe for disaster. This is where folder references come in. They allow you to organize your files into folders on your file system and keep that same folder structure in Xcode.

Xcode 中有两种类型的文件夹:组和文件夹引用。您可以使用组来组织项目中的文件,而不会影响它们在实际文件系统上的结构。这对代码非常有用,因为您将只在 Xcode 中处理您的代码。另一方面,组不太适合资源文件。

在任何相当复杂的项目中,您通常会处理数十个(如果不是数百个)资产文件,并且这些资产需要由您或设计师从 Xcode 外部修改和操作。将所有资源文件放在一个平面文件夹中是一种灾难。这就是文件夹引用的用武之地。它们允许您将文件组织到文件系统上的文件夹中,并在 Xcode 中保持相同的文件夹结构。

Reference

参考

回答by DBoyer

A folder in Xcode represents a folder in the file system.

Xcode 中的文件夹代表文件系统中的文件夹。

A group in Xcode is a "fake" folder which does NOT represent a folder in the file system.

Xcode 中的组是一个“假”文件夹,它不代表文件系统中的文件夹。

It is common to use a combination of groups and folders for a given Xcode project.

对于给定的 Xcode 项目,通常使用组和文件夹的组合。

回答by software evolved

Xcode behavior (starting with v9) has changed and groups are now actual folders on-disk.

Xcode 行为(从 v9 开始)已更改,组现在是磁盘上的实际文件夹。

回答by code4latte

I found that Xcode 9.2 has two versions of group when you create a group. One is groupthe other is group without folder. The first one also creates folder in your file system, the second one doesn't.

我在创建组时发现 Xcode 9.2 有两个版本的组。一个是group另一个是group without folder。第一个也在您的文件系统中创建文件夹,第二个不会。

回答by Mark A. Donohoe

There are lots of answers here on SO that explain the basic differences, but there are some subtle details that are omitted from most answers. I've attempted to put together a detailed and concise explanation in this Q/A-style answer which you can find here...

这里有很多关于 SO 的答案可以解释基本差异,但是大多数答案都忽略了一些微妙的细节。我试图在这个 Q/A 风格的答案中整理出详细而简洁的解释,你可以在这里找到...

What's the detailed difference between a Group and Folder Reference in Xcode?

Xcode 中的组和文件夹引用之间的详细区别是什么?