xcodexcode6xcode-template

Make a dependent target with an Xcode 6 template


In Xcode 5, the Dependencies key along with an array of integers will indicate to create a dependency from another created target to the current target.

     <key>Dependencies</key>
        <array>
            <integer>1</integer>
        </array>

This indicates make the 1st target a dependency on the current (0th) one:

enter image description here

However in Xcode 6, the second target does not even get generated and the following gets logged to the console:

9/23/14 3:26:58.520 PM Xcode[14870]: Invalid target dependency for template from /Users/paulb/Library/Developer/Xcode/Templates/Project Templates/Application/TestApplication.xctemplate

From the debugger, it looks like Xcode 6 is expecting a string instead of an integer. Replacing the integer with a string will get rid of the console error and both targets get generated. However, the dependency does not get generated even if the string is the name of the target:

enter image description here

What needs to be done in a template to get Xcode 6 to create a target dependency?

Full .xctemplate here


Solution

  • Xcode 6 expects a string instead of a integer value for the Dependencies array. The string refers to the value of the new TargetIdentifer key.

    For example, the zeroth (depending) target is changed from:

         <key>Dependencies</key>
            <array>
                <integer>1</integer>
            </array>
    

    to

         <key>Dependencies</key>
            <array>
                <string>mylib</string>
            </array>
    

    and the first (dependent) target has the following new key:

         <key>TargetIdentifier</key>
            <string>mylib</string>