How do I make my custom Xcode project template add a file, e.g., README.md
, to the project group (in the Project Navigator)?
The following steps puts the README.md
file in the root project directory (on the filesystem) but in the group named after the target. How do I add it to the project group?
Add README.md
to the project template's root directory.
Add the following key-value pairs to the TemplateInfo.plist
.
<key>Definitions</key>
<dict>
<key>../README.md</key>
<dict>
<key>Path</key>
<string>README.md</string>
<key>TargetIndices</key>
<array/>
</dict>
</dict>
and
<key>Nodes</key>
<array>
<string>../README.md</string>
</array>
I include them in the project by right-clicking on the project folder in the project view in Xcode, and selecting "Add Files to ...". I then navigate to the folder containing the source files, click on the folder and select "Add." With the options "Create folder references" and "Add to target [target name]".
You can create a new group, with its own folder, directly in Xcode, but it's not at all obvious. Instead of choosing 'New Group', choose 'Add Files to “<Project>”'. Then, in the file picker dialog, click the New Folder button or press Command-Shift-N and type the name of the new folder/group.
Just drag the resource file (from a finder window) into your project files area (left side) and drop in supporting files. Once you drop, a dialog will prompt you which targets to add it for. Select all that are appropriate. Thats it.
add Definitions in TemplateInfo.plist
<key>FolderName/README.md</key>
<dict>
<key>Path</key>
<string>FolderName/README.md</string>
<key>Group</key>
<array>
<string>FolderName</string>
</array>
</dict>
and
add Nodes
<string>FolderName/README.md</string>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With