Auto-increment build number

How do you get the build system to auto-increment the build number? I always forget to advance it and I’m having to build everything twice. It does this in iOS.

(Thread was originally about slow builds but after the first time it went much faster)