Skip to content

Normalize macOS version #61

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jun 24, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Project.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name = "ObjectiveC"
uuid = "e86c9b32-1129-44ac-8ea0-90d5bb39ded9"
version = "3.4.1"
version = "3.4.2"

[deps]
CEnum = "fa961155-64e5-5f13-b03f-caf6b980ea82"
Expand Down
21 changes: 15 additions & 6 deletions src/version.jl
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ end
const darwin_version = OncePerProcess{VersionNumber}() do
_syscall_version("kern.osrelease")
end
const macos_version = OncePerProcess{VersionNumber}() do
const _macos_version = OncePerProcess{VersionNumber}() do
_syscall_version("kern.osproductversion")
end
else
Expand All @@ -35,15 +35,24 @@ else
_darwin_version[]
end

const _macos_version = Ref{VersionNumber}()
function macos_version()
if !isassigned(_macos_version)
_macos_version[] = _syscall_version("kern.osproductversion")
const __macos_version = Ref{VersionNumber}()
function _macos_version()
if !isassigned(__macos_version)
__macos_version[] = _syscall_version("kern.osproductversion")
end
_macos_version[]
__macos_version[]
end
end

function macos_version(normalize=true)
ver = _macos_version()
if normalize && ver.major == 16
# on older SDKs, macOS Tahoe (26) is reported as v16.
# normalize this to v26 regardless of the SDK to simplify use.
return VersionNumber(26, ver.minor, ver.patch)
end
return ver
end
@doc """
ObjectiveC.darwin_version()::VersionNumber

Expand Down