How to add "New Group with Folder" in custom project template by using Xcode 9.x?

1.2k Views Asked by At

I have a custom Xcode project template which generates a project and adds los of Swift boilerplate source files in custom folders. My problem is that I can only create group folders like this: enter image description here, which represents a Group not associated with a file system directory. It's not good because if you later rename a folder in Xcode, it will have no effect on the corresponding file system directory.

My goal is to write an Xcode project template that adds my custom boilerplate swift files in real reference folders like this: enter image description here

Please help me to achieve this. Thank You :)

2

There are 2 best solutions below

1
On

For me it works on right click. However, if it already is a Group with folder it will display New Group without Folder

right click on Groups

0
On

Here is my solution. In the node section specify the group before naming the file.

<key>Nodes</key>
<array>
<string>MyGroup/File.swift:comments</string>
<array>

Next in the definitions provide the group name in the key like so:

<key>Definitions</key>
<dict>
<key>MyGroup/File.swift</key>
<dict>
<key>Path</key>
<string>File.swift</string>
<key>Group</key>
<string>MyGroup</string>
</dict>

Hopefully this will help.