Hi, I am trying to use AAUSBAccessoryManager with mac os 27 to connect host usb device to guest vm.
here is my code
//
// USBPassthroughManager.swift
// VirtualProg
import AccessoryAccess
import Foundation
import IOKit
@available(macOS 27.0, *)
class USBPassthroughManager: NSObject, ObservableObject, AAUSBAccessoryListener {
static let shared = USBPassthroughManager()
@Published var availableDevices: [AAUSBAccessory] = []
func startListening() async {
do {
let existing = try await AAUSBAccessoryManager.shared
.registerListener(self, matchingCriteria: [])
await MainActor.run {
self.availableDevices = existing
}
} catch {
LogManager.shared.log(vmName: AppConstants.logGeneral, type: .error,
message: "USB passthrough listener failed: \(error.localizedDescription)")
}
}
func usbAccessoryDidConnect(_ usbAccessory: AAUSBAccessory) {
DispatchQueue.main.async {
guard !self.availableDevices.contains(where: { $0.registryID == usbAccessory.registryID }) else { return }
self.availableDevices.append(usbAccessory)
print(self.displayName(for: usbAccessory))
}
}
The usb icon in status bar menu is displayed and i can select the the usb device to connect to my app. the usb device is connected to my app. it is shown in the status bar.
but usbAccessoryDidConnect is not firing.
i have the entitlement com.apple.developer.accessory-access.usb in the capabilities.
i get this in the xcode console
start failed ((iokit/common) not permitted) for plugin for ..........
and also disconnect is also not firing. Not sure what i am doing wrong.
How can i determine the name of the USB Device from AAUSBAccessory.
Any help would be appreciated.
Thanks