OSVersion() for macOS Ventura/Sonoma/Sequoia
OSVersion() for macOS Ventura/Sonoma/Sequoia
Edit: This has now been implemented as of 6.12 B2
Hi,
macOS 15 (Sequoia) has recently been released. OSVersion() doesn't yet support it, though, with the latest it supports being #PB_OS_MacOSX_12 (released three years ago!). Can later OS detection support on Mac's possibly be added to the core?
Thanks!
Hi,
macOS 15 (Sequoia) has recently been released. OSVersion() doesn't yet support it, though, with the latest it supports being #PB_OS_MacOSX_12 (released three years ago!). Can later OS detection support on Mac's possibly be added to the core?
Thanks!
Last edited by Quin on Fri Aug 16, 2024 3:07 pm, edited 2 times in total.
Re: OSVersion() for macOS Ventura
Workaround ...
Code: Select all
;-TOP by mk-soft, Update 30.11.2024
; Link: https://www.purebasic.fr/english/viewtopic.php?t=80194
CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
#PB_OS_MacOSX_13 = 13000
#PB_OS_MacOSX_14 = 14000
#PB_OS_MacOSX_15 = 15000
Structure udtOSVersion
majorVersion.i
minorVersion.i
patchVersion.i
EndStructure
Procedure MacOSVersion()
Static NSVersion.udtOSVersion
Protected Version, NSProcessInfo
If Not NSVersion\majorVersion
NSProcessInfo = CocoaMessage(0, 0, "NSProcessInfo processInfo")
CocoaMessage(NSVersion, NSProcessInfo, "operatingSystemVersion")
EndIf
Version = NSVersion\majorVersion * 1000 + NSVersion\minorVersion * 10
ProcedureReturn Version
EndProcedure
Procedure.s OSVersionString()
Static NSVersion.udtOSVersion
Protected Version.s, NSProcessInfo
If Not NSVersion\majorVersion
NSProcessInfo = CocoaMessage(0, 0, "NSProcessInfo processInfo")
CocoaMessage(NSVersion, NSProcessInfo, "operatingSystemVersion")
EndIf
Version = "" + NSVersion\majorVersion + "." + NSVersion\minorVersion + "." + NSVersion\patchVersion
ProcedureReturn Version
EndProcedure
Macro OSVersion()
MacOSVersion()
EndMacro
CompilerEndIf
If OSVersion() >= #PB_OS_MacOSX_15
MessageRequester("Info", "OS Version Sequoia " + OSVersionString())
ElseIf OSVersion() >= #PB_OS_MacOSX_14
MessageRequester("Info", "OS Version Sonoma" + OSVersionString())
ElseIf OSVersion() >= #PB_OS_MacOSX_13
MessageRequester("Info", "OS Version Ventura " + OSVersionString())
EndIf
Last edited by mk-soft on Sat Nov 30, 2024 12:04 pm, edited 2 times in total.
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: OSVersion() for macOS Ventura
Amazing, thanks a lot for this!
Would still love to see this make it into the stdlib, though

Re: OSVersion() for macOS Ventura
With macOS Sonoma rapidly approaching public release, I'm going ahead and bumping this. Both Ventura and Sonoma constants would be great! 

Re: OSVersion() for macOS Ventura
Bumping once again. I now have an application that collects information about the OS a user is running, and it's incredibly unhelpful nowadays to just get Future for 13 and 14. This also seems like the sort of thing that 6.10 is after.
Re: OSVersion() for macOS Ventura
Reference: https://www.purebasic.fr/english/viewto ... on#p591872
Courtesy of mk-soft
Courtesy of mk-soft
Code: Select all
;-TOP my mk-soft, Update 28.11.2022
CompilerIf #PB_Compiler_OS = #PB_OS_MacOS
CompilerIf Not Defined(PB_OS_MacOSX_13, #PB_Constant)
#PB_OS_MacOSX_13 = 13000
Structure udtOSVersion
majorVersion.i
minorVersion.i
patchVersion.i
EndStructure
Procedure MacOSVersion()
Static NSVersion.udtOSVersion
Protected Version, NSProcessInfo
If Not NSVersion\majorVersion
NSProcessInfo = CocoaMessage(0, 0, "NSProcessInfo processInfo")
CocoaMessage(NSVersion, NSProcessInfo, "operatingSystemVersion")
EndIf
Version = NSVersion\majorVersion * 1000 + NSVersion\minorVersion * 10
ProcedureReturn Version
EndProcedure
Macro OSVersion()
MacOSVersion()
EndMacro
CompilerEndIf
CompilerEndIf
Debug OSVersion()
If OSVersion() >= #PB_OS_MacOSX_13
MessageRequester("Info", "OS Version Ventura")
EndIf
Re: OSVersion() for macOS Ventura
What's the constant for Sonoma? I tried 14000 but that didn't seem to work.
mrbungle wrote: Mon Jan 15, 2024 10:32 pm Reference: https://www.purebasic.fr/english/viewto ... on#p591872
Courtesy of mk-soft
Code: Select all
;-TOP my mk-soft, Update 28.11.2022 CompilerIf #PB_Compiler_OS = #PB_OS_MacOS CompilerIf Not Defined(PB_OS_MacOSX_13, #PB_Constant) #PB_OS_MacOSX_13 = 13000 Structure udtOSVersion majorVersion.i minorVersion.i patchVersion.i EndStructure Procedure MacOSVersion() Static NSVersion.udtOSVersion Protected Version, NSProcessInfo If Not NSVersion\majorVersion NSProcessInfo = CocoaMessage(0, 0, "NSProcessInfo processInfo") CocoaMessage(NSVersion, NSProcessInfo, "operatingSystemVersion") EndIf Version = NSVersion\majorVersion * 1000 + NSVersion\minorVersion * 10 ProcedureReturn Version EndProcedure Macro OSVersion() MacOSVersion() EndMacro CompilerEndIf CompilerEndIf Debug OSVersion() If OSVersion() >= #PB_OS_MacOSX_13 MessageRequester("Info", "OS Version Ventura") EndIf
Re: OSVersion() for macOS Ventura
Update on top: https://www.purebasic.fr/english/viewto ... 72#p591872
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: OSVersion() for macOS Ventura
With macOS Sequoia dev beta 1, the following addition to mk-soft's script works nicely.
Would love to see this in core though, it's quite out-of-date now...
Code: Select all
#PB_OS_MacOSX_15 = 15000
re: [done] OSVersion() for macOS Ventura/Sonoma/Sequoia
Done as of 6.12 B2 

Re: OSVersion() for macOS Ventura/Sonoma/Sequoia
Update 30.11.2024 on top

OS Version Sequoia 15.1.1
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive