Xcode 9 folder references with custom project template
Here is what you need to do. 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.
For That purpose one can use Components as used in imessages template
Example of component is
<key>Components</key> <array> <dict> <key>Identifier</key> <string>com.apple.dt.unit.messagesextensioncomponentios</string> <key>Name</key> <string>___PACKAGENAME___ MessagesExtension</string> <key>ProductBuildPhaseInjections</key> <array> <dict> <key>TargetIdentifier</key> <string>com.apple.dt.messagesOnlyApp</string> </dict> </array> </dict> </array>