title: Creating groups using a custom template xcode 8
body: <p>I have successfully created an Xcode 8 template that will respond to these actions:</p>
  
  <ol>
  <li>You already have a working project</li>
  <li>You want to add your custom swift file to this project</li>
  </ol>
  
  <p><strong>Step by step, how to achieve that:</strong></p>
  
  <p>I have created under:</p>
  
  <pre><code>/Users/*YOUR_USER_NAME*/Library/Developer/Xcode/Templates/File Templates
  </code></pre>
  
  <p>The folder name <code>Custom/Interactor.xctemplate</code></p>
  
  <p>Files inside that folder:</p>
  
  <ul>
  <li>___FILEBASENAME___Interactor</li>
  <li>TemplateInfo.plist</li>
  <li>TemplateIcon.png</li>
  <li>TemplateIcon@2x.png</li>
  </ul>
  
  <p>So when I right click and create new file, I will choose the custom file:</p>
  
  <p><a href="https://i.stack.imgur.com/BLDL4.png" rel="noreferrer"><img src="https://i.stack.imgur.com/BLDL4.png" alt="create new file"></a></p>
  
  <p><a href="https://i.stack.imgur.com/sNEAO.png" rel="noreferrer"><img src="https://i.stack.imgur.com/sNEAO.png" alt="Creating custom file"></a></p>
  
  <p>The above example works and creates my custom file:</p>
  
  <p><a href="https://i.stack.imgur.com/FeX1e.png" rel="noreferrer"><img src="https://i.stack.imgur.com/FeX1e.png" alt="successfully creating a custom file"></a></p>
  
  <p><strong>What I am trying to achieve:</strong></p>
  
  <p>I am trying to create a group that will contain the new custom file. No need for an actual folder or complicated tasks, simply a group that contains the actual file.</p>
  
  <p>So the end result will be:</p>
  
  <p><a href="https://i.stack.imgur.com/VjHSN.png" rel="noreferrer"><img src="https://i.stack.imgur.com/VjHSN.png" alt="enter image description here"></a></p>
  
  <p>Since there is no documentation explaining how to create a custom template I have used many references: <a href="http://www.telerik.com/blogs/how-to-create-custom-project-templates-in-xcode-7" rel="noreferrer">ref1</a>, <a href="https://robots.thoughtbot.com/creating-custom-xcode-templates" rel="noreferrer">ref2</a>, <a href="https://stackoverflow.com/questions/5445640/creating-sub-groups-in-xcode-4-templates?noredirect=1&amp;lq=1">ref3</a>, <a href="https://stackoverflow.com/questions/5445640/creating-sub-groups-in-xcode-4-templates">ref4</a>.</p>
  
  <p>Here is the <code>TemplateInfo.plist</code> file:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
  &lt;plist version="1.0"&gt;
  &lt;dict&gt;
      &lt;key&gt;DefaultCompletionName&lt;/key&gt;
      &lt;string&gt;MyCustomInteractor&lt;/string&gt;
    &lt;key&gt;Description&lt;/key&gt;
    &lt;string&gt;Custom interactor&lt;/string&gt;
    &lt;key&gt;Kind&lt;/key&gt;
    &lt;string&gt;Xcode.IDEKit.TextSubstitutionFileTemplateKind&lt;/string&gt;
    &lt;key&gt;Options&lt;/key&gt;
    &lt;array&gt;
          &lt;dict&gt;
              &lt;key&gt;Description&lt;/key&gt;
              &lt;string&gt;Custom interactor&lt;/string&gt;
              &lt;key&gt;Identifier&lt;/key&gt;
              &lt;string&gt;fileName&lt;/string&gt;
              &lt;key&gt;Name&lt;/key&gt;
              &lt;string&gt;Custom name&lt;/string&gt;
              &lt;key&gt;NotPersisted&lt;/key&gt;
              &lt;true/&gt;
              &lt;key&gt;Required&lt;/key&gt;
              &lt;true/&gt;
              &lt;key&gt;Type&lt;/key&gt;
              &lt;string&gt;text&lt;/string&gt;
          &lt;/dict&gt;
      &lt;dict&gt;
              &lt;key&gt;Default&lt;/key&gt;
              &lt;string&gt;___VARIABLE_fileName:identifier___&lt;/string&gt;
              &lt;key&gt;Identifier&lt;/key&gt;
              &lt;string&gt;productName&lt;/string&gt;
              &lt;key&gt;Type&lt;/key&gt;
              &lt;string&gt;static&lt;/string&gt;
      &lt;/dict&gt;
      &lt;dict&gt;
              &lt;key&gt;Default&lt;/key&gt;
              &lt;string&gt;___VARIABLE_fileName:identifier___Interactor&lt;/string&gt;
              &lt;key&gt;Description&lt;/key&gt;
              &lt;string&gt;The interactor name&lt;/string&gt;
              &lt;key&gt;Identifier&lt;/key&gt;
              &lt;string&gt;interactorName&lt;/string&gt;
              &lt;key&gt;Name&lt;/key&gt;
              &lt;string&gt;Interactor Name:&lt;/string&gt;
              &lt;key&gt;Required&lt;/key&gt;
              &lt;true/&gt;
              &lt;key&gt;Type&lt;/key&gt;
              &lt;string&gt;static&lt;/string&gt;
      &lt;/dict&gt;
    &lt;/array&gt;
    &lt;key&gt;Platforms&lt;/key&gt;
    &lt;array&gt;
          &lt;string&gt;com.apple.platform.iphoneos&lt;/string&gt;
    &lt;/array&gt;
      &lt;key&gt;SortOrder&lt;/key&gt;
      &lt;string&gt;99&lt;/string&gt;
  &lt;/dict&gt;
  &lt;/plist&gt;
  </code></pre>
  
  <p><strong>What I have tried:</strong></p>
  
  <p>I have tried to insert <a href="https://stackoverflow.com/questions/5445640/creating-sub-groups-in-xcode-4-templates">this</a> answer into my TemplateInfo.plist but nothing happens. In my opinion it could be related to a scope issue - perhaps I am not inserting the <code>Definitions</code> or the <code>Nodes</code> keys in the right place. The xml <code>Definitions</code> and <code>Nodes</code> code snip I have been struggling with:</p>
  
  <pre><code>&lt;key&gt;Definitions&lt;/key&gt;
  &lt;dict&gt;
      &lt;key&gt;___FILEBASENAME___Interactor.swift&lt;/key&gt;
      &lt;dict&gt;
          &lt;key&gt;Group&lt;/key&gt;
          &lt;string&gt;Custom Interactor&lt;/string&gt;
          &lt;key&gt;Path&lt;/key&gt;
          &lt;string&gt;___FILEBASENAME___Interactor.swift&lt;/string&gt;
      &lt;/dict&gt;
  &lt;/dict&gt;
  
  &lt;key&gt;Nodes&lt;/key&gt;
  &lt;array&gt;
      &lt;string&gt;___FILEBASENAME___Interactor.swift&lt;/string&gt;
  &lt;/array&gt;
  </code></pre>
  
  <p>So where should I insert those keys or what am I doing wrong ?</p>
  
  <p><strong>Any</strong> help would be much appreciated.</p>
  
  <p>Thanks.</p>