Xcode 4 builds everything into $HOME/Library/Developer/Xcode/DerivedData/$PROJECT-$UUID, where $UUID is a seemingly random string (it’s not really random, it just looks random).
How can I reliably detect the $PROJECT-$UUID part of the above? I’ve seen a script (https://gist.github.com/949831) that guesses by assuming it is the last modified directory in DerivedData — but that’s not true if my CI machine is building a few projects in parallel.
Nobody answered, so I kept looking for ideas until I found the one below, which satisfies my needs. It can be further modified to be even safer.
ln -sf "$BUILD_DIR" BuildDirNow, when the target is built a symlink to the project’s DerivedData directory will be created in the project directory.
If desirable, you can also/instead create BuildDir as a file who’s content is the $BUILD_DIR:
echo "$BUILD_DIR" > BuildDirThen in a script use
$(cat BuildDir)to retrieve it.