I have a program which needs to behave slightly differently on Tiger than on Leopard. Does anybody know of a system call which will allow me to accurately determine which version of Mac OS X I am running. I have found a number of macro definitions to determine the OS of the build machine, but nothing really good to determine the OS of the running machine.
Thanks, Joe
From the Apple menu in the corner of your screen, choose About This Mac. You should see the macOS name, such as macOS Monterey or macOS Big Sur, followed by its version number. If you need to know the build number as well, click the version number to see it.
macOS 11.3, iOS 14.5, iPadOS 14.5, watchOS 7.4 and tvOS 14.5. The command uname -r in Terminal will show the Darwin version number ("20.3. 0"), and the command uname -v will show the XNU build version string, which includes the Darwin version number.
See this article here
But in short, if you're using carbon, use the Gestalt() call, and if you're using cocoa, there is a constant called NSAppKitVersionNumber which you can simply check against.
Edit: For Mac OSX 10.8 and above, don't use Gestalt() anymore. See this answer for more details: How do I determine the OS version at runtime in OS X or iOS (without using Gestalt)?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With