When attempting to access a USB device on macOS using IOUSBHostDevice, I get the following error:
Error:Failed to create IOUSBHostObject. with reason: Exclusive open of usb object failed
So, to workaround that error, I've added the following entitlement:
com.apple.vm.device-access
But that leads to an error with attempting to run the application:
Exception Type: EXCCRASH (Code Signature Invalid)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXCCORPSE_NOTIFY
Termination Reason: Namespace CODESIGNING, Code 0x1
My code looks like:
I'm not sure what to do to address this issue. Thanks.
Error:Failed to create IOUSBHostObject. with reason: Exclusive open of usb object failed
So, to workaround that error, I've added the following entitlement:
com.apple.vm.device-access
But that leads to an error with attempting to run the application:
Exception Type: EXCCRASH (Code Signature Invalid)
Exception Codes: 0x0000000000000000, 0x0000000000000000
Exception Note: EXCCORPSE_NOTIFY
Termination Reason: Namespace CODESIGNING, Code 0x1
My code looks like:
Code Block objc NSLog(@"Instantiating USBConfig..."); _queue = dispatch_queue_create("usbconfig", DISPATCH_QUEUE_SERIAL); _productId = asusBluetoothDongleProductId; _vendorId = asusBluetoothDongleVendorId; CFMutableDictionaryRef query = [IOUSBHostDevice createMatchingDictionaryWithVendorID:[NSNumber numberWithUnsignedInteger:_vendorId] productID:[NSNumber numberWithUnsignedInteger:_productId] bcdDevice:nil deviceClass:nil deviceSubclass:nil deviceProtocol:nil speed:nil productIDArray:nil]; _service = IOServiceGetMatchingService(kIOMasterPortDefault, query); if (_service == 0) { NSLog(@"No service match found for product/vendor query."); return nil; } kern_return_t authorized = IOServiceAuthorize(_service, 0); if (authorized) { } NSError* error = nil; _device = [[IOUSBHostDevice alloc] initWithIOService:_service options:IOUSBHostObjectInitOptionsDeviceCapture queue:_queue error:&error interestHandler:^(IOUSBHostObject * _Nonnull hostObject, uint32_t messageType, void * _Nullable messageArgument) { NSLog(@"Interest handler..."); }]; if (error != nil) { NSLog(@"Error creating device: %@", [error localizedDescription]); }
I'm not sure what to do to address this issue. Thanks.