From 4b2b4eca89e6657df56d958cab4c088265445a03 Mon Sep 17 00:00:00 2001 From: Rachel Brindle Date: Fri, 22 Jul 2022 18:59:41 -0700 Subject: [PATCH] xcode 14 removes the kIOMasterPortDefault symbol --- Sources/Validation.swift | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/Sources/Validation.swift b/Sources/Validation.swift index 96448ef..434faca 100644 --- a/Sources/Validation.swift +++ b/Sources/Validation.swift @@ -323,7 +323,12 @@ func getMacAddress() -> Data? func ioService(named name: String, wantBuiltIn: Bool) -> io_service_t? { - let master_port = kIOMasterPortDefault + let main_port: mach_port_t + if #available(macOS 12.0, macCatalyst 15.0, *) { + main_port = kIOMainPortDefault + } else { + main_port = 0 // the kIOMasterPortDefault symbol is unavailable on xcode 14 and later. + } var iterator = io_iterator_t() defer @@ -334,8 +339,8 @@ func ioService(named name: String, wantBuiltIn: Bool) -> io_service_t? } } - guard let matchingDict = IOBSDNameMatching(master_port, 0, name), - IOServiceGetMatchingServices(master_port, matchingDict as CFDictionary, &iterator) == KERN_SUCCESS, + guard let matchingDict = IOBSDNameMatching(main_port, 0, name), + IOServiceGetMatchingServices(main_port, matchingDict as CFDictionary, &iterator) == KERN_SUCCESS, iterator != IO_OBJECT_NULL else {