Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Xcode Project Template: Add file to the project group

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?

  1. Add README.md to the project template's root directory.

  2. 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>
    
like image 595
ma11hew28 Avatar asked Mar 21 '13 21:03

ma11hew28


People also ask

How do I add files to target in Xcode?

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]".

How do I group files in Xcode?

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.

How do I add resources to my Xcode project?

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.


1 Answers

  1. You can put README.md file into Project template/FolderName
  2. 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

  1. add Nodes

    <string>FolderName/README.md</string>
    
like image 94
Pratik Lad Avatar answered Oct 16 '22 16:10

Pratik Lad