multiple build targets in xcode
Any idea how I would go about configuring xcode to build me multiple max objects from the same project – say if I had a project called xyz and wanted to build the two different objects ‘xyz.123′ and ‘xyz.456′ using the separate source files 123.c and 456.c.
Duplicate your target (or create a new one with all the right settings), and then drop down the target arrow so that you can see the various build stages. One of these is "Compile Sources" – which shows the source files that will compile for that target – you can edit them by drag-n-drop etc….. You’ll also need to alter settings like product name etc. for each target.
If you want to be able to build multiple sources with a single press then create an aggregate target which has all the other targets you want to build together as dependencies. The XCode docs cover this in detail.
I believe the cv.jit collection of objects has this configuration and uses the "aggregate target" as Alex mentions above. I learned a few things from the way that project was setup and the conventions used therein. Kudos to Jean-Marc Pelletier (or whoever created that XCode project.) Nice work!
Since I just managed to do it, I wish to share my personal recipe for having multiple targets and build them with one click – and when in 6 months I will need to do the same for another project and I won’t remember how the hell I had done this I will go back to the forum and find this…
1. Copy a project from the sdk, change its name and remove all the source files you don’t need.
2. Go into "targets", add a new aggregate target.
3. Besides the aggregate, you should have a single target called "max-external". Rename it with a more expressive name, open its info window, go to build->product name (make sure you’re editing all the build configurations) and type in there the name of the external.
4. Drag the target you just edited onto the aggregate.
5. If you want another target, copy the one you just made and go back to step 2.
6. Drag your sources, one by one, onto the "Source" group. For every source, you will be asked what external(s) you want it to be part of. You can always change this by going into your target folder and changing the "copy headers" and "compile sources" folders.
Voilà. Now you should be able to separatedly compile any of your external, or build them all together, by choosing the appropriate active target from your Overview menu.
… I hope I didn’t forget any step! I have found out this by trial-and-error and some internet research – I guess this is not the only way to do it, and not necessarily the best, and maybe it has drawbacks… Any commentary or suggestion is welcome!
Forums > Dev