I know about the various ways to check the OS version like [[NSProcessInfo processInfo] operatingSystemVersion]
, Gestalt
, NSAppKitVersionNumber
, etc.
However these methods don't tell me whether a specific OS version is a beta or a stable release.
Is there a reliable way to detect if the current OS version is a beta release without hardcoding version numbers?
The reason I'm looking into a way to detect this is to notify users of my app of potential incompatibilities when running a macOS beta.
macOS beta build numbers end in an alpha character.
#!/bin/sh
version=$(/usr/bin/sw_vers -buildVersion | /usr/bin/sed -e 's/\(^.*\)\(.$\)/\2/')
if [[ "${version}" =~ [0-9] ]]; then
echo "Not Beta"
else
echo "Beta"
fi
exit
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