I came up with proof-of-concept solution that works, but will require some work to use in production. Basically, I set up a new "External Target", which compiles all source files in a given directory into a static library. Then the static library is linked into the Main Application.
In detail:
- Create a directory (lets call it 'Code') inside your project directory and put some source code in it.
- Create a Makefile in the Code directory to compile the source into a static library. Mine looks like this.*
- Create an External Target (lets call it 'ExternalCode') and point it to the Code directory where your source and Makefile reside.
- Build the ExternalCode and create a reference to the compiled static library (ExternalCode.a) in the Products area of your project. Get Info on the reference and change the Path Type to "Relative to Built Product".
- Make sure ExternalCode.a is in the "Link With Binary Libraries" section of your main target.
- Add the ExternalCode target as a dependency of your main target
- Add the Code directory to your "User Header Search Paths" of your main target.
Now when you drop some source files into 'Code', Xcode should recompile everything. I created a demo project as a proof of concept. To see it work in, copy B.h/m from the 'tmp' directory into the 'Codes' directory.
*Caveats: The Makefile I provided is oversimplified. If you want to use it in a real project, you'll need to spend some time getting all the build flags correct. You'll have to decide whether it's worth it to manually manage the build process instead of letting Xcode handle most of the details for you. And watch out for paths with whitespace in them; Make does not handle them very well.