Many developers are using script to increment build number after each deployment. I don’t like this approach because it provides no info about a builds other than ordering. Since Apple requires this to be increasing number - commits hash can’t be used. But it is possible to use number of commits in current branch - this allows to quickly find a commit for any build deployed.
Also my approach only changes plist in build results, so nothing appear in git status for woking directory.
Add script to new build phase: ProjectName > TargetName > Build Phases > New Run Script Phase.
Script can be just dropped as a text here, but I prefer to store it separately, so I am adding:
And here is shell script:
Accessing app version and build number in runtime
For every my project I am adding short log of current bundle id + version + build number in AppDelegate.
Finding commit for build number
If you want to get commit hash from build number, add this command to [alias] section of your ~/.gitconfig:
And then use it in your working directory (don’t forget to be on your correct release branch):