title: Run a shell script before build in Xcode
body: <p>I need to adjust my build and version number for my project before build/archiving.<br>
  I tried multiple things, but so far to no avail.</p>
  
  <p>I added a target with the script to update the numbers and added that as first dependency to my main target. But because I have multiple dependencies as I have extensions in my app and all dependencies are executed by Xcode in parallel (or at least in random order) this does not work. </p>
  
  <p>I added a pre-action to my scheme with the same result. Xcode is not waiting for my pre-action to complete before continuing with the build (I added a sleep 100 to test).</p>
  
  <p>As I'm altering build numbers it is crucial that the script can complete before anything else is started, but there is also one more side-effect: The build even stops due to the fact that the plist files have been altered while building the related target.</p>
  
  <p>What makes it more difficult is, that I would like to use <a href="https://stackoverflow.com/questions/29399947/how-to-automatically-set-the-version-and-build-number-of-a-watchkit-app-target/29450194#29450194"><code>agvtools</code></a> to set my version &amp; build number. This obviously starts background processes that are out of my control to alter the plists.</p>
  
  <p>Disclaimer: I have searched for <a href="https://stackoverflow.com/questions/13340823/how-to-make-xcode-run-a-script-before-dependencies">other answers</a>, didn't help.</p>