I have a script that I run using osascript from a Run Script Build Phase in Xcode 4. This script does some checks to try and catch any human-error in plists and suchlike.
If you don't do 3. the script will run all the time, but if you check that box, it will only run when archiving.