3

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 :)

rmaddy
  • 314,917
  • 42
  • 532
  • 579
Naveen Sharma
  • 311
  • 2
  • 8
  • I can't help you without more details about your project template, but you might find some useful information in [this answer](https://stackoverflow.com/a/17286494/77567). Specifically read the “Impossible-to-deduce details” section. – rob mayoff Aug 02 '18 at 14:26
  • 1
    Thank you @robmayoff. But what I'm actually trying to do is that I'm trying to create a custom project template with the already defined folder structure like Xcode provide "Single View App.xctemplate", "Tabbed App.xctemplate" etc. You can check default provided templates at path "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/iOS/Application". But with my custom template, while editing TemplateInfo.plist, I'm only able to add "Group" not "New Group with Folder". – Naveen Sharma Aug 03 '18 at 07:52

2 Answers2

2

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.

8azan
  • 148
  • 1
  • 10
0

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

Nicolas Degen
  • 1,522
  • 2
  • 15
  • 24
  • 2
    Thank you @nicolasdegen. Yes, I know how to create "New Group with Folder" in an existing project folder. But here I,m asking to add the same in custom templates. You can check default provided templates by Xcode at path "/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/Library/Xcode/Templates/Project Templates/iOS/Application". But with my custom template, while editing TemplateInfo.plist, I'm only able to add "Group" not "New Group with Folder". – Naveen Sharma Aug 03 '18 at 08:52