11

I've been trying to add a Copy Files build phase to a project template for Xcode 4 but I cannot figure out how to add files to copy.

Here's what I've added to my target. Changes to DstPath, DstSubfolderSpec and RunOnlyForDeploymentPostprocessing are all reflected in projects created from the template. But no files. I have tried adding an array using keys named Files, Definitions, Nodes, nothing has any affect.

Any thoughts or ideas would be greatly appreciated!

        <key>BuildPhases</key>
        <array>
            <dict>
                <key>Class</key>
                <string>CopyFiles</string>
                <key>DstPath</key>
                <string></string>
                <key>DstSubfolderSpec</key>
                <string>10</string>
                <key>RunOnlyForDeploymentPostprocessing</key>
                <string>NO</string>
            </dict>
        </array>
David Rogers
  • 111
  • 3
  • Is there a reason you're doing it in XML and not through the GUI? – Ben Mosher Jun 13 '11 at 12:27
  • He is creating a XCode template. – Jano Jun 15 '11 at 11:44
  • the best i could find was a post in the developer forum quoting someone "in the know" at WWDC stating that this is not supported; this would jive with my attempt to find an appropriate string name via 'strings DevToolsCore' that would correspond to the necessary recognized string in the plist: it presents the strings DstPath and DstSubfolderSpec near the string 'Copy Files', but there's not a string that would refer to an array of files as is generated when you do this graphically in Xcode. i tried the string 'buildFiles', but it was not recognized for that part of the .plist . – john.k.doe Jul 31 '12 at 21:17
  • Did anyone ever find out how to do this? – Santhosh R Jan 23 '18 at 20:55

3 Answers3

2

I found a little gem hidden in some weird python script that gave a "better" (as opposed to nothing) explanation of the mysterious DstSubfolderSpec

# dstSubfolderSpec property value used in a PBXCopyFilesBuildPhase object.
'BUILT_PRODUCTS_DIR': 16,  # Products Directory
 : 1,                      # Wrapper
 : 6,                      # Executables: 6
 : 7,                      # Resources
 : 15,                     # Java Resources
 : 10,                     # Frameworks
 : 11,                     # Shared Frameworks
 : 12,                     # Shared Support
 : 13,                     # PlugIns

There's actually quite a bit of interesting info in the script, (apparently it's part of pythonwebkit, or something).. but regardless, I posted a gist of it here if you want to try and glean any other useful tidbits.

Alex Gray
  • 16,007
  • 9
  • 96
  • 118
1

So far I have this working:

<dict>
    <key>Class</key>
    <string>CopyFiles</string>
    <key>DstPath</key>
    <string>www</string>
    <key>DstSubfolderSpec</key>
    <string>7</string>

This creates a CopyFiles build phase that copies files to the folder "www" inside of Resources. (This would result in those files living under /www in the app bundle.) However, I haven't yet been able to specify which files get copied. This is similar to this question

Community
  • 1
  • 1
thrusty
  • 864
  • 1
  • 8
  • 18
0

I don't know the answer but this may be a workaround. It runs a script with each build.

<key>Targets</key>
<array>
    <dict>
        <key>BuildPhases</key>
        <array>
            <dict>
                <key>Class</key>
                <string>ShellScript</string>
                <key>ShellPath</key>
                <string>/bin/sh</string>
                <key>ShellScript</key>
                <string>~/hello.sh</string>
            </dict>

enter image description here

Note that the path to the script is absolute. Maybe you can define a path with PathType Group to set it relative to a group inside the project (I didn't try).

DstPath is the destination path of the files to copy (I guess). I don't know what DstSubfolderSpec is, it only appears in the Command Line Tool with a value of 0. I guess you don't know it either.

Jano
  • 62,815
  • 21
  • 164
  • 192