From 56a6d0ff3752570de89f00876eb7181d662a0465 Mon Sep 17 00:00:00 2001 From: Ellet <73608287+freshtechtips@users.noreply.github.com> Date: Fri, 17 Nov 2023 11:33:59 +0300 Subject: [PATCH] fix(device_info_plus): Fix deprecation warning on MacOS (#2377) Co-authored-by: Nico Mexis Co-authored-by: Volodymyr Buberenko --- .../device_info_plus/macos/Classes/SystemUUID.swift | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/packages/device_info_plus/device_info_plus/macos/Classes/SystemUUID.swift b/packages/device_info_plus/device_info_plus/macos/Classes/SystemUUID.swift index cc9e9ae2b1..0b93b221dd 100644 --- a/packages/device_info_plus/device_info_plus/macos/Classes/SystemUUID.swift +++ b/packages/device_info_plus/device_info_plus/macos/Classes/SystemUUID.swift @@ -4,7 +4,14 @@ public struct SystemUUID { public static func getSystemUUID() -> String? { let dev = IOServiceMatching("IOPlatformExpertDevice") - let platformExpert: io_service_t = IOServiceGetMatchingService(kIOMasterPortDefault, dev) + + var platformExpert: io_service_t + if #available(macOS 12, *) { + platformExpert = IOServiceGetMatchingService(kIOMainPortDefault, dev) + } else { + platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault, dev) + } + let serialNumberAsCFString = IORegistryEntryCreateCFProperty(platformExpert, kIOPlatformUUIDKey as CFString, kCFAllocatorDefault, 0) IOObjectRelease(platformExpert) let ser: CFTypeRef? = serialNumberAsCFString?.takeUnretainedValue() @@ -13,4 +20,4 @@ public struct SystemUUID { } return nil } -} \ No newline at end of file +}