What’s in a number: how Big Sur could break code

Much that we do in scripts, tools and apps has to take into account the many changes that have happened in macOS. We normally manage these with conditional statements, in pseudo-code
if (macOS.minorVersion = 15) then …
These make assumptions about how Apple numbers versions of macOS, and could be about to break with the release of macOS 11 Big Sur.

Look at any of the images showing Big Sur running in WWDC, and you’ll see that it’s officially branded as macOS 11. If rumours are true, this seems to have been a fairly late decision, and for much of its development it has been known instead as macOS 10.16. Indeed, it seems that this first beta-release, while proclaiming itself as macOS 11, actually calls itself 10.16 internally.

Numbering versions of macOS follows a standard set of rules. The version consists of three distinct integer components:

  1. The first is the major version number, which ran up to 9 in Classic Mac OS, and has been 10 ever since the first release of Mac OS X.
  2. The second is the minor version number, which in Classic days seldom rose much. In recent Mac OS X, though, there’s been a new version each year, such as Catalina 10.15 and Mojave 10.14. It’s this version which is most commonly used when deciding which features are available.
  3. The third is the patch number. In recent macOS, this has risen to x.x.6 at the end of each release cycle. Although some features depend on patch numbers, that’s less common.

According to that, Big Sur is either 10.16.0 or 11.0.0, depending on where you look. If your conditional code has only been checking for minor version numbers, then it would see Catalina as 15, but Big Sur could be either 16 or 0 depending on how Apple numbers it. If the major version has indeed incremented for the first time in the last 20 years or so, and Big Sur turns out to be 11.0.0, then anything which assumes that this minor version number will be greater than 15 will break. If the major version number hasn’t incremented, then the minor version number will be 16, as at present.

I’m a great believer in covering all outcomes whenever possible. In my code, where I need to test for Big Sur, I now use code like
if (macOS.minorVersion > 15) or (macOS.minorVersion < 10) then …
which is good for code which can’t or won’t run on anything before Yosemite.

No matter what Apple may eventually settle on, I shouldn’t have to change that again for many years. If your code reads
if (macOS.minorVersion > 15) then …
it will break if Apple settles on Big Sur as being 11.0.0. If it instead reads
if (macOS.majorVersion = 11) then …
it won’t work on the current beta, but might work if Apple changes the version numbering.