Get OSX version number?

Does anyone know of a way to get the OSX version number in UXP?

Does this work? Seems to work on Windows…

const result = await batchPlay([
    {_obj: "get", _target: [
        {_property: "osVersion"},
        {_ref: "application", _enum: "ordinal", _value: "targetEnum"}
], {});

Yes, that works, thanks :slight_smile:

Somehow I overlooked that property.

You can also use:

const version = require('uxp').host.version;

That gives the Photoshop version, not the operating system version.

What about platform() and release() from the os module?

This returns “win32” for any Windows System and “darwin” for any Mac system. I’m already using that to determine Windows vs Mac.

This one is strange. It gives the correct OS release for windows 10.0.19044. My OS build is 19044.1526. So 19044 is what matters here. For Mac, it is returning 21.2.0. The OSX version is Monterey 12.1.0. This was ran form the pre-release beta 23.2.0. Not sure where 21.2.0 is coming from. I don’t even have PS 21 installed on the system so it couldn’t be referring to a PS version.

1 Like

BatchPlay it is then :slight_smile:

Which is fine. I have 10 plugins that are all nearly 100% batchPlay anyway. I’m not going to go back and rewrite them all over again using DOM now that they are done. So I may as well just stay consistent :slight_smile:

For macOS, platform and release return the Darwin version. This is typical behavior on Node and other environments, and is normal. The catch is that the Darwin version for Montery is 21.x. You can validate this by running uname -a in the terminal:

$ uname -a
Darwin machine-name.local 21.3.0 Darwin Kernel Version 21.3.0: Wed Jan  5 21:37:58 PST 2022; root:xnu-8019.80.24~20/RELEASE_ARM64_T6000 arm64

That 21.3.0 is the value returned by require("os").release(). macOS version history - Wikipedia has a good mapping of the major versions from macOS to Darwin.

Thanks for the clarification. I was wondering if it was something like that. So the “Darwin” version was incrementing by 1 every year while the OSX version was stuck at 10.X for many years.

There are 2 option then for UXP which is good because you can get whichever version you want.

  1. Using the batchPlay option for osVersion will return the OSX version of 12 for Monterey.

  2. Using release() will return the darwin version of 21.