I am collaborating on a project right now where multiple developers may be making changes to a single Xcode project. Since in my experience, Xcode project files “don’t merge well,” we have setup git so it treats the Xcode project file (project.pbxproj) as if it were a binary. Consequently, it sucks to have too many outstanding changes to the Xcode project file that have to be merged back in manually. To help shorten the amount of time someone might be working on an out of date Xcode project file, I setup a post-commit hook on the git repository that sends email to the developers in case this particular file changes.
- Add the following “hooks” section to the config file for the target git repository, of course updating the email(s) as appropriate:
[hooks] mailinglist = email@example.com firstname.lastname@example.org
- In the “hooks” directory in your repository, you should find a file named “post-commit.” Add the following to the file:
git show --pretty="format:" --name-only HEAD | grep project.pbxproj if [ $? -eq 0 ]; then mail $(git config hooks.mailinglist) -s "Xcode project changed" <<-EOF Please pull the latest Xcode project. EOF fi
- Make the post-commit file executable if you have not done so already.
chmod +x post-commit
That’s it! Piece o’ cake, huh? Anyway, even if my logic regarding the “mergability” (or lack thereof) of an Xcode project is flawed, the principle behind email notification on a single file is still valid. I’m sure generalizing this to notify upon changes to a list of files is easy enough.