How to programmatically detect Mac OS X Server Edition?

Does anyone know of any API that can help distinguish Mac OS X "Server edition" from "Desktop edition"? My app should know which version of Mac OS X is currently running. (Server or desktop)

+4
source share
3 answers

sw_vers seems to do this by checking /System/Library/CoreServices/ServerVersion.plist - you could get around just seeing if the file exists.

+6
source

If there is a real reason why your application should know this, I would recommend checking for the presence of a component that matters on the desktop / server. For example, if the server version comes with a program or library foo , but not in the desktop version, and you would like to use foo and then check for the existence (and / or version) of foo instead of trying to get it out of Server vs Desktop OS.

(Meanwhile, the sw_vers and system_profiler SPSoftwareDataType commands are one possible starting point for checking the OS version.)

+3
source

Perhaps you can find the difference using the sysctl API or Gestalt

+1
source

Source: https://habr.com/ru/post/1307030/


All Articles