2

I am running an application built using C++ on new macOS 12 Monterey beta. The application is built using macOS SDK 10.9 which is quite old.

The Problem: There is a code to fetch the platform version, where i parse the content of System/Library/CoreServices/SystemVersion.plist file using Core-Foundation API. Instead of returning macOS version as 12.0 the application is reading it as 10.16. There is no flaw in code since same code has been in use for identifying many older macOS versions.

Probable Cause: Something has changed during macOS 11.0 bigSur release wherein there is another file name SystemVersionCompat.plist that is in same location as SystemVersion.plist. My application is reading the former instead of later plist and on some web search got to know its because of use of older SDK.

Content of System/Library/CoreServices/SystemVersion.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>ProductBuildVersion</key>
    <string>21A5304g</string>
    <key>ProductCopyright</key>
    <string>1983-2021 Apple Inc.</string>
    <key>ProductName</key>
    <string>macOS</string>
    <key>ProductUserVisibleVersion</key>
    <string>12.0</string>
    <key>ProductVersion</key>
    <string>12.0</string>
    <key>iOSSupportVersion</key>
    <string>15.0</string>
</dict>
</plist>

Content of System/Library/CoreServices/SystemVersionCompat.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>ProductBuildVersion</key>
    <string>21A5304g</string>
    <key>ProductCopyright</key>
    <string>1983-2021 Apple Inc.</string>
    <key>ProductName</key>
    <string>Mac OS X</string>
    <key>ProductUserVisibleVersion</key>
    <string>10.16</string>
    <key>ProductVersion</key>
    <string>10.16</string>
    <key>iOSSupportVersion</key>
    <string>15.0</string>
</dict>
</plist>

Is there any other convenient way to get the platform version without updating SDK ?

santosh
  • 61
  • 7
  • 2
    If you open the wrong file, then there's most likely a problem in your code. Unfortunately we can't help you with that since you don't show it. Perhaps it's time to refresh [the help pages](http://stackoverflow.com/help), take the SO [tour], read [ask], as well as [this question checklist](https://codeblog.jonskeet.uk/2012/11/24/stack-overflow-question-checklist/). And don't forget how to create a [mre] to show us. – Some programmer dude Sep 08 '21 at 05:54
  • 1
    See https://eclecticlight.co/2020/08/13/macos-version-numbering-isnt-so-simple/ – Alan Birtles Sep 08 '21 at 06:16
  • Yes @AlanBirtles is right that article exactly defines my problem. macOS plays a trick when opening SystemVersion.plist file. Iam looking for a workaround without updating SDK. – santosh Sep 08 '21 at 06:18
  • Why don't you want to update the sdk? – Alan Birtles Sep 08 '21 at 06:35
  • The ROI is not worth it, only thing i want to achieve is get macOS version but updating SDK can lead to more testing , so looking for workaround with current SDK itself – santosh Sep 08 '21 at 06:44
  • 2
    10.16 means 11.0 or higher as the transition point between 10.x and 11.0... https://developer.apple.com/documentation/foundation/nsoperatingsystemversion `NSOperatingSystemVersion` structure is usable if you are willing to ditch 10.9 for an upgrade to 10.10. – Richard Barber Sep 08 '21 at 07:13
  • This sort of sucks, because NSProcess:operatingSystemVersionString also returned the exact build number, too. But that won't work on Monterey. – SMGreenfield Sep 30 '21 at 00:35
  • @RichardBarber - Turns out NSOperatingSystemVersion DOESN'T work on Monterey. It also returns 10.16.0... – SMGreenfield Sep 30 '21 at 02:37

1 Answers1

5

You can set environment variable SYSTEM_VERSION_COMPAT = 0 (either in plist file or in code itself before reading the file) and that will give you correct version.

run below commands on terminal and you will see the difference:

SYSTEM_VERSION_COMPAT=1 cat /System/Library/CoreServices/SystemVersion.plist

SYSTEM_VERSION_COMPAT=0 cat /System/Library/CoreServices/SystemVersion.plist

  • 1
    This did it for me, though I do wish Apple had some documentation on SYSTEM_VERSION_COMPAT so that I could verify that the version is the only thing that is different between SystemVersion.plist and SystemVersionCompat.plist. – ilinamorato Jan 11 '22 at 17:58