Page 1 of 1
OSVersion() for macOS Ventura/Sonoma/Sequoia
Posted: Mon Nov 28, 2022 4:04 pm
by Quin
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!
Re: OSVersion() for macOS Ventura
Posted: Mon Nov 28, 2022 9:48 pm
by mk-soft
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
Re: OSVersion() for macOS Ventura
Posted: Tue Nov 29, 2022 2:27 pm
by Quin
Amazing, thanks a lot for this!

Would still love to see this make it into the stdlib, though
Re: OSVersion() for macOS Ventura
Posted: Wed Sep 06, 2023 7:24 pm
by Quin
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
Posted: Mon Jan 15, 2024 9:23 pm
by Quin
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
Posted: Mon Jan 15, 2024 10:32 pm
by mrbungle
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
Posted: Tue Jan 16, 2024 12:13 am
by Quin
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
Posted: Tue Jan 16, 2024 6:40 pm
by mk-soft
Re: OSVersion() for macOS Ventura
Posted: Tue Jun 11, 2024 11:25 pm
by Quin
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...
re: [done] OSVersion() for macOS Ventura/Sonoma/Sequoia
Posted: Fri Aug 16, 2024 3:05 pm
by Quin
Done as of 6.12 B2

Re: OSVersion() for macOS Ventura/Sonoma/Sequoia
Posted: Sat Nov 30, 2024 12:05 pm
by mk-soft
Update 30.11.2024 on top
OS Version Sequoia 15.1.1