Skip to content

Commit

Permalink
Update SystemUUID.swift
Browse files Browse the repository at this point in the history
Fix For older Maxos platforms.
#available(macOS 12, *) is not available on runtime for older platforms it must be replaced by Compiletime directive
#if MACOS12_OR_LATER
  • Loading branch information
fmatuszewski authored Sep 17, 2024
1 parent b645a11 commit 9e1098c
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@ public struct SystemUUID {
let dev = IOServiceMatching("IOPlatformExpertDevice")

var platformExpert: io_service_t
if #available(macOS 12, *) {
#if MACOS12_OR_LATER
print("Running on macOS 12 or newer")
platformExpert = IOServiceGetMatchingService(kIOMainPortDefault, dev)
} else {
#else
print("Running on an older version of macOS")
platformExpert = IOServiceGetMatchingService(kIOMasterPortDefault, dev)
}
#endif

let serialNumberAsCFString = IORegistryEntryCreateCFProperty(platformExpert, kIOPlatformUUIDKey as CFString, kCFAllocatorDefault, 0)
IOObjectRelease(platformExpert)
Expand Down

0 comments on commit 9e1098c

Please sign in to comment.