Why in Xcode, Groups can be created, but not real folders?

后端 未结 3 1474
悲&欢浪女
悲&欢浪女 2021-01-30 13:02

When doing iOS programming, it is interesting that in Xcode (4.3.2), we can create groups, such as a group call Images, and add files to it (either as a link or cho

相关标签:
3条回答
  • 2021-01-30 13:41

    There is a Command Line Tool - "synx" available in github that do exactly what you need.

    It reorganizes Xcode project folder in finder to match Xcode groups in project.

    You can find it here: https://github.com/venmo/synx

    UPDATE: XCode 9 supports this feature by default. So, no need to use other tools anymore!

    0 讨论(0)
  • 2021-01-30 13:52

    Note: In Xcode 10, the default behavior now creates a linked folder when you create a new group. The information below still applies otherwise.

    The recommended way to organize files is via groups, because it's more flexible than creating directories, and allows you to create complex file hierarchies while maintaining a totally different file hierarchy on the file system. It's simply an organization tool. That said, it is possible to turn groups into folder references, or create them initially as folder references.

    Furthermore, using groups instead of folder references gives you greater flexibility if you need to change where things are in the file system - say you have a common folder of code that you use in a bunch of different projects. Groups allow you to organize the files inside of projects as if they were in the projects, while still maintaining one copy of the code in a central location. And yes, you can do this with folder references as well, but groups are much more flexible if you later want to add other things to the same group but don't want them to be added to that common folder.

    If you want to link a group to a folder, click on the group in the project file tree and hit command+option+1. Below the drop down that'll say something like "Path: Relative to Group" on the right, there's a little white square with a grey border around it kinda icon next to the word "none". Clicking on this and then selecting/creating a folder will bind the group to the folder.

    folder reference

    Furthermore, when you drag a folder into Xcode, it will ask you if you want it to be a group or a folder reference:

    adding a folder reference

    0 讨论(0)
  • 2021-01-30 13:52

    This is a pet peeve of mine.

    I recommend, making the folder in your file system, where you have your project files, then drag that folder into Xcode where you want the group. It will act like any other group, but now be linked to the folder on the file system. Adding files to that group in Xcode now adds them to the folder in the file system.

    Much cleaner way of working and helps when locating files in big projects. Keeps git cleaner too.

    Update for Xcode 9:

    Once you have the groups in Xcode matching the directory structure on disk, moving a file from one group to another in Xcode will now move the file correctly on disk to match.

    0 讨论(0)
提交回复
热议问题