--- bee.lua/bee/platform/version.cpp +++ bee.lua/bee/platform/version.cpp 2025-08-08 02:59:34.000000000 +0800 @@ -1,7 +1,7 @@ #include #if defined(__APPLE__) -# include +# include #else # if defined(_WIN32) # include @@ -70,28 +70,20 @@ version os_version() { #if defined(__APPLE__) - // id processInfo = [NSProcessInfo processInfo] - id processInfo = reinterpret_cast(objc_msgSend)(objc_getClass("NSProcessInfo"), sel_getUid("processInfo")); - if (!processInfo) { - return { 0, 0, 0 }; + SInt32 major = 0, minor = 0, bugfix = 0; + if (Gestalt(gestaltSystemVersionMajor, &major) != noErr || + Gestalt(gestaltSystemVersionMinor, &minor) != noErr || + Gestalt(gestaltSystemVersionBugFix, &bugfix) != noErr) { + SInt32 version = 0; + if (Gestalt(gestaltSystemVersion, &version) == noErr) { + major = ((version & 0xFF00) >> 8); + minor = ((version & 0x00F0) >> 4); + bugfix = (version & 0x000F); } - struct OSVersion { - int64_t major_version; - int64_t minor_version; - int64_t patch_version; - }; -# if defined(_M_ARM64) || defined(__aarch64__) -# define msgSend objc_msgSend -# else -# define msgSend objc_msgSend_stret -# endif - // NSOperatingSystemVersion version = [processInfo operatingSystemVersion] - OSVersion version = reinterpret_cast(msgSend)(processInfo, sel_getUid("operatingSystemVersion")); - return { - static_cast(version.major_version), - static_cast(version.minor_version), - static_cast(version.patch_version) - }; + } + return {static_cast(major), + static_cast(minor), + static_cast(bugfix)}; #elif defined(_WIN32) OSVERSIONINFOW osvi = {}; osvi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOW);