Skip to content

Commit

Permalink
fix(device_info_plus): Fix deprecation warning on MacOS (#2377)
Browse files Browse the repository at this point in the history
Co-authored-by: Nico Mexis <[email protected]>
Co-authored-by: Volodymyr Buberenko <[email protected]>
  • Loading branch information
3 people authored Nov 17, 2023
1 parent 76d0665 commit 56a6d0f
Showing 1 changed file with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -13,4 +20,4 @@ public struct SystemUUID {
}
return nil
}
}
}

0 comments on commit 56a6d0f

Please sign in to comment.