( jur - nay - sic ) Entrepreneur / Software Engineer

How To Auto-Increment Your iOS Version Number

Previously I wrote up how to auto-increment your build number.  I mentioned how I wanted to figure out how to do the same for the version number.  The thing that makes the version number different and more difficult is that version numbers generally have sub-versions.  My bash scripting skills are minimal so I did not take on the task at the time and planned to revisit it.

Well Paul Capestany picked it up where I left off.  You can see his solution on github.  To understand how to install and use this script, please see the previous post for instructions.

I like Paul’s solution, but one thing that does not appeal to me is that the build number is used for the last piece of the version number, i.e. 2.4.X.  The way I see things, the build number is a continuously incrementing number that should never be reset.  So I went on and edited the script so that the last section increment by one every time, just like the build number.  The intention behind this is that it will be reset (manually of course) when you do major version updates.

Here is the script that I ended up with (you can find the github gist here):

I ended up leaving the incrementing of the build numbers in there, as I generally use both and I figure pretty much everybody else will as well.

One thing that may come up is that this only works for the last section of the version number.  I figure you always want to update this piece.  Unfortunately you cannot do the same with the first two sections.  The computer really cannot tell when you are releasing a “significant” build, so as mentioned previously it is best to update those two manually when you make major revisions to your app.

Thanks again to Paul Capestany for commenting on the previous post with his solution.  It was immensely helpful in coming up with this.

Follow Us

Follow our activity on the web and get to know us.