Copy Headers that preserves subdirectory structure?

  • Is there a way to have the Copy Headers build phase preserve the
    subdirectory structure for the header files?

    I've got a BSD static library project that provides some FreeBSD and
    Linux emulation for cross-compiling unit-tests on OS X. As part of
    the emulation, I need to install headers like sys/callout.h and cam/
    cam.h in my Public Headers Folder Path. Unfortunately, the Xcode Copy
    Headers build phase seems to flatten the directory structure and
    install all the headers at the top level of Public Headers Folder. Is
    there some setting that can instruct Copy Headers to preserve a
    relative path for a header file?

    The alternative seems to be to copy the headers in a Run Script build
    phase. Does Xcode export PUBLIC_HEADERS_FOLDER_PATH as  an
    environment variable?

    TIA.

    Regards,
    -Steve

    --
    Steve Byan <stevebyan...>
    Littleton, MA 01460
  • Hi Steve -

    On Oct 11, 2007, at 11:58 AM, Steve Byan wrote:
    > Is there a way to have the Copy Headers build phase preserve the
    > subdirectory structure for the header files?
    >
    > I've got a BSD static library project that provides some FreeBSD and
    > Linux emulation for cross-compiling unit-tests on OS X. As part of
    > the emulation, I need to install headers like sys/callout.h and cam/
    > cam.h in my Public Headers Folder Path. Unfortunately, the Xcode
    > Copy Headers build phase seems to flatten the directory structure
    > and install all the headers at the top level of Public Headers
    > Folder. Is there some setting that can instruct Copy Headers to
    > preserve a relative path for a header file?
    >
    > The alternative seems to be to copy the headers in a Run Script
    > build phase. Does Xcode export PUBLIC_HEADERS_FOLDER_PATH as  an
    > environment variable?

    Try adding the folder containing the header to Xcode as a folder
    reference, and then add that to the Copy Headers build phase (you'll
    probably have to drag-drop it into the phase rather than checking the
    checkbox in the detail view).  Folder references are the mechanism
    Xcode provides for preserving a directory hierarchy during a copy.
    See the Xcode documentation for more information.

    --
    Michael Rawdon
    <rawdon...>
    Xcode Developer
    Apple Inc., Cupertino CA
  • On Oct 11, 2007, at 3:11 PM, Michael Rawdon wrote:

    >> On Oct 11, 2007, at 11:58 AM, Steve Byan wrote:
    >> Is there a way to have the Copy Headers build phase preserve the
    >> subdirectory structure for the header files?
    >
    > Try adding the folder containing the header to Xcode as a folder
    > reference, and then add that to the Copy Headers build phase
    > (you'll probably have to drag-drop it into the phase rather than
    > checking the checkbox in the detail view).  Folder references are
    > the mechanism Xcode provides for preserving a directory hierarchy
    > during a copy.  See the Xcode documentation for more information.

    Thanks, I always wondered what the "Create Folder References" radio-
    button was about. Now I know.

    Regards,
    -Steve

    --
    Steve Byan <stevebyan...>
    Littleton, MA 01460
  • At one point I was using a "Run Script Phase" that had the following
    contents:

    #------------------
    echo 'SRCROOT:'${SRCROOT}
    cd ${SRCROOT}

    # I have to move up a directory due to my layout.
    echo 'Copying Usul Headers into Framework..'
    cd ../
    for H in `find ./Usul -name "*.h"`;  do
        echo ${H}
        ditto ${H} ${BUILT_PRODUCTS_DIR}/${H}
    done
    #------------

    The key was using ditto with the find command.

    Here is the relevant thread from a few years back. A radar bug was
    filed but I have no idea if it was ever fixed.

    http://lists.apple.com/archives/xcode-users/2005/Jul/msg00025.html

    --
    Mike Jackson  Senior Research Engineer
    Innovative Management & Technology Services

    On Oct 11, 2007, at 3:19 PM, Steve Byan wrote:

    >
    > On Oct 11, 2007, at 3:11 PM, Michael Rawdon wrote:
    >
    >>> On Oct 11, 2007, at 11:58 AM, Steve Byan wrote:
    >>> Is there a way to have the Copy Headers build phase preserve the
    >>> subdirectory structure for the header files?
    >>
    >> Try adding the folder containing the header to Xcode as a folder
    >> reference, and then add that to the Copy Headers build phase
    >> (you'll probably have to drag-drop it into the phase rather than
    >> checking the checkbox in the detail view).  Folder references are
    >> the mechanism Xcode provides for preserving a directory hierarchy
    >> during a copy.  See the Xcode documentation for more information.
    >
    > Thanks, I always wondered what the "Create Folder References" radio-
    > button was about. Now I know.
    >
    > Regards,
    > -Steve
    >
    > --
    > Steve Byan <stevebyan...>
    > Littleton, MA 01460
    >
    >
    > _______________________________________________
    > Do not post admin requests to the list. They will be ignored.
    > Xcode-users mailing list      (<Xcode-users...>)
    > Help/Unsubscribe/Update your Subscription:
    > http://lists.apple.com/mailman/options/xcode-users/imikejackson%
    > 40gmail.com
    >
    > This email sent to <imikejackson...>
  • Hi Mike,

    Thanks for the pointer. I did a spotlight search on my personal xcode-
    users archive thinking that it went back pretty far, but upon
    checking I find that my archive only goes back to January 2006. I
    should have used google.

    On Oct 12, 2007, at 9:05 AM, Mike Jackson wrote:

    > Here is the relevant thread from a few years back. A radar bug was
    > filed but I have no idea if it was ever fixed.
    >
    > http://lists.apple.com/archives/xcode-users/2005/Jul/msg00025.html

    The bug was fixed; Michael Rawdon's suggestion was to make use of the
    fix. It's not perfect, however, as it copies everything in the
    directory, not just the header files (with some exceptions - Xcode
    excludes .DS_Store files, CVS directories, and .svn directories).
    Unless there's some magic Xcode setting to add file patterns to
    filter out, your shell script solution looks the best if the source
    directory structure includes anything other than header files.

    Regards,
    -Steve

    --
    Steve Byan <stevebyan...>
    Littleton, MA 01460
  • Mike Jackson wrote:

    > echo 'SRCROOT:'${SRCROOT}
    > cd ${SRCROOT}
    >
    >
    > # I have to move up a directory due to my layout.
    > echo 'Copying Usul Headers into Framework..'
    > cd ../
    > for H in `find ./Usul -name "*.h"`;  do
    > echo ${H}
    > ditto ${H} ${BUILT_PRODUCTS_DIR}/${H}
    > done

    As given, the unquoted expansions may fail if any pathname contains
    embedded whitespace, with possibly horrible consequences.  This is what
    double-quotes are for.

    Suggested minimum improvements:
      ...
      cd "${SRCROOT}"
      ...
        echo "${H}"
        ditto "${H}" "${BUILT_PRODUCTS_DIR}/${H}"

      -- GG
  • Agreed. That was written when I was still "wet behind the ears". I
    actually do not use that project any more but the clarification is
    definitely welcome.

    Cheers.
    --
    Mike Jackson  Senior Research Engineer
    Innovative Management & Technology Services

    On Oct 12, 2007, at 2:54 PM, Greg Guerin wrote:

    > Mike Jackson wrote:
    >
    >> echo 'SRCROOT:'${SRCROOT}
    >> cd ${SRCROOT}
    >>
    >>
    >> # I have to move up a directory due to my layout.
    >> echo 'Copying Usul Headers into Framework..'
    >> cd ../
    >> for H in `find ./Usul -name "*.h"`;  do
    >> echo ${H}
    >> ditto ${H} ${BUILT_PRODUCTS_DIR}/${H}
    >> done
    >
    > As given, the unquoted expansions may fail if any pathname contains
    > embedded whitespace, with possibly horrible consequences.  This is
    > what
    > double-quotes are for.
    >
    > Suggested minimum improvements:
    > ...
    > cd "${SRCROOT}"
    > ...
    > echo "${H}"
    > ditto "${H}" "${BUILT_PRODUCTS_DIR}/${H}"
    >
    > -- GG
    >
    >
    > _______________________________________________
    > Do not post admin requests to the list. They will be ignored.
    > Xcode-users mailing list      (<Xcode-users...>)
    > Help/Unsubscribe/Update your Subscription:
    > http://lists.apple.com/mailman/options/xcode-users/imikejackson%
    > 40gmail.com
    >
    > This email sent to <imikejackson...>
previous month october 2007 next month
MTWTFSS
1 2 3 4 5 6 7
8 9 10 11 12 13 14
15 16 17 18 19 20 21
22 23 24 25 26 27 28
29 30 31        
Go to today