Mac XCode multiple-executable in one project?

Status
Not open for further replies.

Jeff S

Ars Legatus Legionis
11,958
Subscriptor++
I wasn't sure whether to put this here or in the Mac forum, but I think since it is a programming question, it's probably better here?

Well, anyhow, here goes.

I'm very new to Mac OS and Mac programming. I've been tasked with writing a small number of small test programs (probably 10 or 20 programs). The programs need to be CLI programs, so that they can be launched automatically from a testing tool (they shouldn't require any user interaction). Additionally, I've decided to create a small static library, to include a function to run some common startup and login code that I'm going to need to run for basically all of the tests (this way, I can just import a header file at the top of each test program, then run a single line of code to invoke all the common startup code as a function).

The problem I'm wrestling with at the moment is how to organize my XCode workspace. I'm thinking about creating all of the test programs in a single XCode project, with each program being a seperate 'target'. Currently I have one test program, and also the static library, as 2 targets in the project. Can anyone tell me of any pitfalls to that approach?

Is there some way I can configure the project so that it knows that each of the other executable targets are 'dependent' on the library, so that it will automatically re-build the library, as needed, when I build the rest of the targets? Is there a quick way to build all targets at once (so I don't have to select them each individually and build them)?
 
Yes, targets can depend on each other. The info inspector for a target will let you set up dependancies. You have to add the target as a dependency and in the same window also add the library as a library to link to.

As for building all targets, I know that CMake adds a target with everything else as a dependency. I don't know if that's the 'normal' Xcode way or not, or if there are better alternatives.
 
Status
Not open for further replies.