Within a shared Workspace, how can multiple Projects share a set of .xcconfig files?

I have a set of .xcconfig files, that form a mesh of sorts through the #include mechanism. There are some basic components (e.g. perhaps a boost.xcconfig that lets me change the base of the boost include hierarchy if I have multiple installations on this machine) and then higher-level components and .xcconfig files that might each include several lower-level components.


Then I have a bunch of legacy library + command-line-tool + unit-test projects, primarily used by linux-based products but which need to run on macOS as well. Each one of these I access via folder references. There is a lot of similarity between these products, and it would be very useful for me to be able to know I was setting up corresponding Xcode Projects consistently (one per product) with them. I thought that it would be possible to do this with .xcconfig files.


So I made an 'Empty' Project, and put the .xcconfig files into it. Call this Project S.


Then as I created the other Projects, I tried to set their Debug and Release configurartions to be based on certain of the higher-level components, by referencing the .xcconfig files in Project S. I could not. The only configuration available to me in these other Projects was None.


I tried making Project S a subproject of each of the non-shared Projects, but still, nothing but None available for configuration.


I tried dragging the individual files in Project S into one of the non-shared Projects, but still, nothing but None.


Am I just barking up the wrong tree? I guess I could try having symlinks named Project_X_YYY.xcconfig to Project S's YYY.xcconfig, for all values of YYY, and for all non-shared Projects X0, X1, X2 …; that would be a huge kludge, though.


Can this be done and is there an elegant way to do it?

Replies

Did you try one project w/multiple targets?

You have to add the config files to each project. You don't have to (and probably shouldn't) add then to project targets. Use the "Add Files to " menu sub-item in the file menu, or right-click on the project in the Navigator side panel and use the "Add Files" sub-menu item.

If you are including other config files in the project include files, you will have to be careful about file path names. You either have to put in an absolute pathname, or a relative path name with the starting point being the directory where the project xcodeproj resides (that directory is set up as SRCROOT in the Xcode environment by Xcode when it starts up).