On OS X Beware , although documented to be available in OS X There is also kCFCoreFoundationVersionNumber which can be used if you only need to check for a minimum version to support. This has the advantage that it works going back to Note that even It is recommended in AppKit Release Notes.
This is actually a compilation of answers above, with some further guiding to the developer in need. OS-X provides its version in runtime in several ways.
Each way fits better to specific development scenario. I'll try to summarise them all, and hope that others will complete my answer if I forgot something. For more details on each option - please consult the answers above.
Mac OS X & macOS names
There's plenty of information there! There's uname 3 :. The uname function stores nul-terminated strings of information identifying the current system into the structure referenced by name. While playing around with sysctl on macOS today I stumbled upon kern.
On my Mac running Mojave I get:. This commit to the xnu kernel code base indicates that osproductversion is a recent addition that came in mid I successfully tested it on All in all, the best programmatic, non-Cocoa approach in my opinion would be to check if kern.
Late to the game, but I ended up here looking for an answer as well. For what it's worth, maybe it's of use for someone else;. Gestalt is a pure C API. The accepted answer suggests using NSProcessInfo but that requires Objective-C code and cannot be used if pure C is a requirement for some reason. Reading kern. I wouldn't be surprised if even Swift's available macOS There is just no simple C call for reading the version number from there, so I wrote the following pure C code which only requires CoreFoundation framework that itself is pure C framework:.
The reason for using dispatch once at all is that the version number cannot change while the system is running, so there is no reason for reading the version number more than once during a single app run. Also reading it is not guaranteed to be fail-safe and too expensive to re-read it every time your app may require it. Talking about not being fail-safe, even though it is unlikely, reading it may, of course, fail, in which case the function returns false and always will return false.
What To Do
I leave it up to you to handle that case in a meaningful way in your app code because I cannot know how critical knowing the version number is to your app. If the version number is not critical, maybe you can work around it, otherwise you should make your app fail in a user friendly way. Listen now.
Learn more. Ask Question. Asked 7 years, 4 months ago. Active 5 months ago. Viewed 50k times. Todd Ditchendorf Todd Ditchendorf 7, 14 14 gold badges 60 60 silver badges bronze badges.
There is some discussion about the same thing in this question: stackoverflow. Although they're maintained still, and work, it is not a good idea to use them these days. Not even for runtime version On iOS, these methods are effectively only available since iOS 8. You may also using the following Objective-C category BSD licensed to use these new methods on older operating system versions: github. If I already know I'm on Pierrot 3 3 silver badges 14 14 bronze badges. Variable Length Coder Variable Length Coder 6, 2 2 gold badges 19 19 silver badges 27 27 bronze badges.
- mac mini 2011 usb hub.
- Your Answer!
- Mac OS X - Installation of Ruby on Rails with RVM?
Note that these are the same results you get from uname discussed in Carl Norum's answer. They're kernel version numbers, which map somewhat to OS releases, but not in an obvious way. While you might be able to arithmetically determine one version from another for OS X right now, such comparison is not guaranteed to work in the future. This is also implied by official documentation here under point 'Runtime Version Check' : developer. There is a cocoa API. The code to get the operating System Version String is below..
- Find and activate the Safari update.
- OS X & macOS Build Numbers/Versions – Tech2Max!
- instalar controle ps3 no mac.
Which rather defeats the purpose, at the moment. You can still use Gestalt for now, but it's deprecated and could disappear at any moment.
How to Check What Mac OS Version is Running on a Mac
Oct 6 '14 at It's not deprecated and works on Unfortunately the Apple documentation says The operating system version string is human readable, localized, and is appropriate for displaying to the user. This string is not appropriate for parsing. The answer from Vikas Bansal is arguably better. For example to check for It also works in Swift in the exact same way. Thanks, this is nice, and quite exactly what I was looking for - no need for Appkit linking against Obj-C code and runtime , no need for system calls, file reads, and so on simple constant maintained by the OS.
One thing though - what header should be included for this constant to be available? It is generally a good idea to install all of the available updates, but be aware: this may change how some of your software functions in the future. You should always have a backup of your system before you install System Updates. If you want to upgrade just Safari, click the blue " More " link; this will expand the System Applications, allowing you to pick and choose which updates to install.
The latest version of Safari available for your system will download and install itself. This may take a few minutes depending on the speed of your internet connection.
Apple Releases Mac OS X 10 Lion Developer Preview 2 To Developers | Cult of Mac
In normal circumstances, the App Store will check for updates and prompt you to install them. Here are some guides to update other web browsers like Chrome or Firefox. Homepage Guides How to update your web browser Safari. It should prompt you in the top-right hand corner of the screen when updates are found. If you want to manually check for updates and install them, follow these steps: Open Software Updates Click the Apple menu icon in the top left-hand corner of your screen.
The system menu will appear, click the " Software Update Find and activate the Safari update On this screen, the App Store will show you all of the updates which are available to you.