Reputation: 1229
I have an application containing embedded frameworks. I want to remove the headers from those frameworks when I build the project. However, there are other headers in the app wrapper that I do not want removed. (I am writing an integrated development environment for C and C++ that has to include headers so that the bundled compiler will work.) I have a Run Script phase that uses the Unix find
tool to locate and remove the Headers
and PrivateHeaders
directories (and the symlinks that point to them) from the embedded frameworks. It works fine when I am building for use with Xcode's debugger.
However, when I use Xcode's Archive command to perform a release, the ${BUILT_PRODUCTS_DIR}
variable is no longer expanded correctly. Investigation indicates that it points to a directory that does not exist. Presumably Xcode deleted this directory automatically during the archive procedure, before I can open it in the Finder and see its contents.
How can I get the path to the .app
package directory in a Run Script build phase that works correctly while creating an Xcode archive? I can then remove the headers from within the embedded frameworks by using find
and the ${FRAMEWORKS_FOLDER_PATH}
variable.
I have already tried to remove the headers using a post-action in the Xcode scheme, but that won't work properly, as it removes all header files, not just those within the embedded frameworks. This is because scheme post-actions can't find the .app
directory. (I have tried using the "Provide Build Settings From" pop-up menu, and I have verified through printenv
that it does export the settings properly, but the .app
directory still can't be found.)
Upvotes: 1
Views: 3375
Reputation: 1229
I figured it out for myself. I went into the scheme I'm using when I archive my project and added a Run Script post-action under Archive. Here is the contents of the script I used:
find "${ARCHIVE_PRODUCTS_PATH}/${INSTALL_DIR}/${FRAMEWORKS_FOLDER_PATH}" \
-name "Headers" -exec rm -r {} \;
find "${ARCHIVE_PRODUCTS_PATH}/${INSTALL_DIR}/${FRAMEWORKS_FOLDER_PATH}" \
-name "PrivateHeaders" -exec rm -r {} \;
Note that if you do this for yourself, you must replace the fictitious INSTALL_DIR
variable with the location of your app wrapper. You can find this in the Build Settings screen for your application target; look for "Installation Directory". (The name of the app wrapper is part of the FRAMEWORKS_FOLDER_PATH
variable, which is why you didn't see it above.)
Upvotes: 1