I have been trying to create the Xcode File Template that contains boiler plate files and code structure for MVVM design pattern.
I created a module successfully with custom template using the plist configuration and file structure as below:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Kind</key>
<string>Xcode.IDEFoundation.TextSubstitutionFileTemplateKind</string>
<key>Description</key>
<string>MVVM Module Template.</string>
<key>Summary</key>
<string>MVVM Module Template</string>
<key>Options</key>
<array>
<dict>
<key>Identifier</key>
<string>productName</string>
<key>Required</key>
<true/>
<key>Name</key>
<string>Module Name:</string>
<key>Description</key>
<string>The module name.</string>
<key>Type</key>
<string>text</string>
<key>Default</key>
<string>Base</string>
</dict>
<dict>
<key>Identifier</key>
<string>View</string>
<key>Name</key>
<string>Also create View file for user interface</string>
<key>Description</key>
<string>Create a view file with the same name</string>
<key>Type</key>
<string>checkbox</string>
<key>NotPersisted</key>
<true/>
</dict>
</array>
</dict>
</plist>
Folder Structure For the Custom Template
The problem was that, when I checked the checkbox, all the files in the View folder was created, but when checkbox is not checked, non of the files are created.
What shall I do to achieve following cases:
- Generate source files from the folder 'Source' when checkbox is unchecked.
- Generate source files from the folder 'View' when checkbox is checked.
You're doing it right for when the checkbox is checked, but you need to change the "Source" to "default" for when the checkbox is unchecked.