Xcode: Add a source file property to control bundle destination section
Most of my development is split between cross-platform C projects and Objective-C development for macOS. Using CMake to manage my C libraries makes it very easy to generate an Xcode project for my C libraries in order to readily incorporate them into larger macOS applications. It works great.
Except for one thing that really is driving me nuts.
Say I'm working on a project that creates the target libFoo
. This requires the use of the header file libFoo.h
. Normally, this will be referenced by the master project with #include <libFoo/libFoo.h>
.
No problem, except that the CMake generated Xcode project requires me to manually do the following for it to work properly:
-
Select the desired target (
libFoo
) -
Go to the "Build Phases" tab.
-
Add a new "Copy Files" phase.
-
Set Destination to "Products Directory"
-
Set Subpath to "include/${PRODUCT_NAME}"
-
Select
libFoo.h
and add it to the list of files. -
Repeat if any other header files are required.
-
Repeat for each and every library I include this way
-
Repeat each and every time the Xcode project automatically gets regenerated when I happen to update the underlying library project with a new release with a git pull.
Until all that is done, I cannot use #include <libFoo/libFoo.h>
in my master project.
Now, I could store the Xcode project in my git repo so that I don't have to repeat this. But then I have to manually update every time I add new files to the project, etc. This defeats the purpose of using CMake in the first place. It makes it hard to ensure that CMake and the Xcode project are both kept in a functional state as I continue development.
Questions/Requests
-
I have tried and tried, but cannot find a way do accomplish this automatically. If I missed something, please let me know.
-
If not, then please consider adding support for this. Support for
include/libFoo.h
seems present for other generators, and it should be supported in Xcode as well. -
At the very least, it would be nice if CMake did not "clobber" changes like this that I make manually. I could live with doing this once. But doing it over and over and over gets tiring. ;)
Thank you!!
Fletcher