Search code examples
macosversiondarwin

Extract macOS release name from Darwin/XNU versions


Is there any equation to get macOS version (10.X) from it's corresponding darwin version or xnu version (without having a pre-defined table per version)

For example, In macOS Mojave (10.14) we have the following contents :

darwin version 18.0.0
xnu version 4903.200.249

And in macOS high sierra (10.13) we have :

10.13.3: xnu-4570.41.2  darwin version 17.4.0   
10.13.2: xnu-4570.31.3  darwin version 17.3.0   
10.13.1: xnu-4570.20.62 darwin version 17.2.0
10.13:   xnu-4570.1.46  darwin version 17.0.0   

So I've deduced that the Major number in Darwin version is unique per OS release :

..
16->10.12,
17->10.13, 
18->10.14, 
..

Does my assumption is correct ?


Solution

  • Yep, this is correct for major version numbers. Minor versions sometimes increment even if macOS revision doesn't, and vice versa, as in the case of 10.13.1 where the darwin minor version incremented by 1 for a security release, and again for 10.13.1.