Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <h3>UPDATE</h3> <p>The following describes Xcode 9 and later.</p> <p>Beginning with Xcode 9, Xcode can automatically create a filesystem folder when you create a group in your project.</p> <p>When you right-click (or control-click) in the project navigator, the context menu will include a “New Group” menu item and <strong>either</strong> a “New Group with Folder” menu item <strong>or</strong> a “New Group without Folder” menu item.</p> <ul> <li><p>If Xcode offers “New Group” and “New Group with Folder”, then “New Group” creates a group without a folder.</p></li> <li><p>If Xcode offers “New Group” and “New Group without Folder”, then “New Group” creates a group with a folder.</p></li> </ul> <p>In other words, “New Group” always does the opposite of the other (explicit) menu item, with regard to folder creation.</p> <p>If you rename a group, and that group has a corresponding folder with the same name, Xcode 9 also renames the folder.</p> <p>In Xcode 9, if you drag a file from one group to another, and the groups have different folders, Xcode 9 moves the file to the new group's folder, regardless of whether the new group's folder has the same name as the group.</p> <p>If you <strong>do not</strong> want this behavior in Xcode 9, you can set an undocumented setting from the command line:</p> <pre><code>defaults write com.apple.dt.Xcode IDEDisableStructureEditingCoordinator -bool YES </code></pre> <h3>Impossible-to-deduce details about “New Group with Folder” and “New Group without Folder”</h3> <p>It's not at all obvious how Xcode decides whether to show “New Group” and “New Group with Folder”, or “New Group” and “New Group without Folder”. An Apple engineer at WWDC 2018 (I think his name was Paul) looked at the Xcode source code and explained it to me:</p> <ul> <li>Xcode figures out which group you clicked on (or, if you didn't click a group, it figures out which group contains the item you clicked).</li> <li>Xcode looks at the <strong>subgroups</strong> (and linked folders) that are children of the clicked group.</li> <li>If the majority of the subgroups have their own folders, then Xcode assumes you want the new group to also have its own folder. So Xcode shows “New Group” (which will create a folder) and “New Group without Folder”.</li> <li>If the majority of the subgroups do <strong>not</strong> have their own folders, then Xcode assumes you want the new group to also <strong>not</strong> have its own folder. So Xcode shows “New Group” (which will <strong>not</strong> create a folder) and “New Group with Folder”.</li> <li>I don't know how Xcode breaks the tie if exactly half of the subgroups have their own folders, and I don't feel like testing it right now…</li> <li>If the clicked group has no subgroups, Xcode decides what to show based on whether the clicked group itself has its own folder.</li> </ul> <p>Basically, Xcode tries to guess whether your new group should have its own folder based on whether its future siblings have their own folders.</p> <h3>ORIGINAL</h3> <p>You <strong>can</strong> create a new group, with its own folder, directly in Xcode, but it's not at all obvious.</p> <p>Instead of choosing ‘New Group’, choose ‘Add Files to “&lt;Project&gt;”’. Then, in the file picker dialog, click the New Folder button or press Command-Shift-N and type the name of the new folder/group. Then, make sure “Create groups for any added folders” is chosen and click Add or press Return.</p> <p><a href="https://i.stack.imgur.com/VyiiM.gif" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VyiiM.gif" alt="adding a group with its own folder"></a></p> <p><strong>This doesn't save you much if you need to move existing files into the new group, because Xcode still won't do that.</strong></p> <p>But it does save a few steps if you are creating a new group to hold new files.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload