How can I get the darwin version at runtime?
I know that I can get the macOS or iOS version using [[NSProcessInfo processInfo] operatingSystemVersion]
, but I want the Darwin version.
There are tables on the internet linking macOS and iOS releases to a darwin version, but i want to implement this future-proof.
Use the
uname()
POSIX/BSD library function. You declare a variable of typestruct utsname
and pass in its address. Therelease
field of the struct will contain a C string with the Darwin version number, such as "16.3.0". If you want the individual components as integers, you'll have to parse it yourself.