공식문서로 알아보는 Group/Folder

공식문서로 알아보는 Group/Folder
Photo by Maksym Kaharlytskyi / Unsplash

Xcode에서 파일혹은 폴더를 프로젝트에 추가할 때 위와 같은 옵션을 선택할 수 있도록 가이드 한다.

각각의 설정이 무엇을 의미하는지 알아보자.

💡
Copy items if needed
Project navigator에 추가하기 전에 모든 파일과 폴더를 프로젝트 폴더에 복사한다. 원본 버전 대신 파일의 copy로 작업하려면 해당 옵션을 사용한다.
💡
Create groups
선택한 필드 및 디스크의 folder 구조와 일치하는 group의 구조를 프로젝트에 생성한다.
💡
Create folder references
Project navigator에 folder를 표시하지만, project에 folder를 복사하지는 않는다. project navigator에서 추가된 각 folder는 file system의 folder를 가리킨다.

Group, Folder가 뭘까?

Group을 알아보기에 앞서 먼저 Folder 부터 알아보자

Folder는 프로젝트에서 참조하는 파일 시스템의 디렉토리를 말한다.

따라서 파일 시스템에서 해당 디렉토리가 삭제되면, 프로젝트에서도 해당 파일이 삭제된다.

Group은 Project의 resource collection이다.

기본적으로 Xcode는 각 group을 프로젝트 디렉토리의 Folder에 매핑하지만,
기본 파일 시스템의 폴더 없이 group을 생성할 수도 있다.
disk에 있는 파일을 변경하지 않고 프로젝트의 파일을 관리하는 경우 폴더가 없는 그룹을 사용할 수도 있다.

group이 folder와 연결된 경우 Xcode는 파일 시스템의 folder에 대해 rename, delete, move 및 복사 작업을 진행한다. 이부분을 유의해야할 것 같다.

어떨 때 무엇을 사용할까?

대부분의 경우 group을 사용하지만, 가장 최근의 Asset을 반영할 때와 같이 파일이 항상 동일한 파일이 아닌 경우 프로젝트에서 해당 Folder에 대한 참조를 하여 즉각적으로 반영하고 싶을 때 Folder를 사용하면 좋을 것 같다.

참조

Managing files and folders in your Xcode project | Apple Developer Documentation
Add new or existing files to your project, and use groups to organize the files and folders in the Project navigator.
Xcode: Groups And Folder References
In Xcode you can add folders as groups or as folder references. So what are the differences between these two? Groups If you drag a folder to the project navigator, the following window appears: If you choose “create groups”, then the corresponding folder appears with a yellow icon in t…