Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Detect if macOS version is a beta release

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.

like image 785
lemonmojo Avatar asked Oct 19 '25 15:10

lemonmojo


1 Answers

macOS beta build numbers end in an alpha character.

  • Non-Beta Example: Ventura 13.5.1, Build 22G90
  • Beta Example: Ventura 13.4.1 (c), Build 22F770820d
  • Beta Example: Sonoma 14.0, Build 23A5312d
    #!/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
like image 90
cainehorr Avatar answered Oct 22 '25 03:10

cainehorr



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!