hairloss, due to Xcode
Xcode lets you reorganize your Build Phases, which gave me the impression that I somehow had control over the sequence of the phases. But actually the documentation says something quite different. What should have given me pause for thought is, that you can reorganize your build phases to look like this:
and Xcode will just happily build. Here Xcode is obviously reordering the compile and the link steps. (It's also interesting, that there must be a secret "create DSYM" phase, that isn't being shown in the Build Phases.)
Not that exciting you say ? Probably yes, but not really, if you want to add a phase between compilation and linking. It sure looks like you could do this:
But you can't. Unfortunately trusting dumbass that I am, I thought it was doing what it was supposed to do and lost a good deal of time until I figured out, that the phase order isn't guaranteed and that script 3 was running too late, after the link.
The next mistake I made was to have read the Xcode documentation and going into pedantic mode. I tried to set all the inputs and outputs of all the shell scripts correctly for a guaranteed execution order. In the end that confused Xcode so badly, that some of my script weren't even run anymore. I would avoid this at all cost, because of the danger of severe hairloss.
You can't really predict, which files are of interest to the dependency analyzer and which not. It appeared to me that for instance trying to reference DWARF_DSYM_FILE_NAME was a losing proposition.
Here is a screeny that shows, that it is in principle possible to interpose a script between compilation and linking, if you use versioning (which was exactly, what I was trying to do).
(There must be a secret "compile version output" phase too, that isn't being shown in the Build Phases.)