简体   繁体   中英

Adding Directories to Xcode custom project template creates weird recursion

I am trying to create an Xcode project template that will include a directory filled with classe files using the following in the .plist for the template :

<key>Definitions</key>
<dict>
    <key>Classes</key>
    <dict>
        <key>Path</key>
        <string>Classes</string>
    </dict>
</dict>

<key>Nodes</key>
<array>
    <string>Classes</string>
</array>

This almost works but the last file in Classes always becomes a reference folder to the Classes file creating a weird recursion.

As an example, let's say Classes has 3 files, ah, bh and ch The resulting project will have a file structure that looks like this :

project
+-Classes
  +-a.h
  +-b.h
  +-c.h //This is not a proper .h file, it is a file reference
    +-a.h
    +-b.h
    +-c.h //This is the actual .h file

Is there a clean way to have the project template copy all files from a directory?

After a lot of research, it seems that this is a bug with Xcode's template system. There doesn't seem to be a way to copy directories that contain other files without creating this problem (at least at the time of writing this answer).

The only alternative I was able to find was to manually specify each file inside a directory in the project template, specifying the file's group to match the folder structure.

<key>Definitions</key>
<dict>
    <key>Classes/a.h</key>
    <dict>
        <key>Group</key>
        <array>
            <string>Classes</string>
        </array>
        <key>Path</key>
        <string>Classes/a.h</string>
    </dict>
    <!--Repeat for b and c-->
</dict>

<key>Nodes</key>
<array>
    <string>Classes/a.h</string>
    <!--Repeat for b and c-->
</array>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM