Page 1 of 1

OSX Version check

Posted: Mon Oct 19, 2015 7:23 am
by wilbert
Alternative method to the PB builtin OSVersion() command using NSAppKitVersionNumber

Code: Select all

#NSAppKitVersionNumber10_6 = 1038
#NSAppKitVersionNumber10_7 = 1138
#NSAppKitVersionNumber10_8 = 1187
#NSAppKitVersionNumber10_9 = 1265
#NSAppKitVersionNumber10_10 = 1343
#NSAppKitVersionNumber10_10_Max = 1349

ImportC ""
  dlsym(handle, symbol.p-utf8)
EndImport

*Version.Double = dlsym(-2, "NSAppKitVersionNumber")
AppKitVersionNumber = Round(*Version\d, #PB_Round_Down)


If AppKitVersionNumber < #NSAppKitVersionNumber10_7
  Debug "OSX 10.6 Snow Leopard"
ElseIf AppKitVersionNumber < #NSAppKitVersionNumber10_8
  Debug "OSX 10.7 Lion"
ElseIf AppKitVersionNumber < #NSAppKitVersionNumber10_9
  Debug "OSX 10.8 Mountain Lion"
ElseIf AppKitVersionNumber < #NSAppKitVersionNumber10_10
  Debug "OSX 10.9 Mavericks"
ElseIf AppKitVersionNumber <= #NSAppKitVersionNumber10_10_Max
  Debug "OSX 10.10 Yosemite"
Else
  Debug "OSX 10.11 El Capitan"
EndIf

Re: OSX Version check

Posted: Mon Oct 19, 2015 7:46 am
by Keya
Excellent, thankyou for share! Here's the other 10.x'ers just to round out the party :)

Code: Select all

#NSAppKitVersionNumber10_0 = 577  ;Cheetah   (PowerPC only)
#NSAppKitVersionNumber10_1 = 620  ;Puma      (PowerPC only)
#NSAppKitVersionNumber10_2 = 663  ;Jaguar    (PowerPC only)
#NSAppKitVersionNumber10_3 = 743  ;Panther   (PowerPC only)
#NSAppKitVersionNumber10_4 = 824  ;Tiger     (Intel + PowerPC)
#NSAppKitVersionNumber10_5 = 949  ;Leopard   (Intel + PowerPC)