USBDeviceSwift
USBDeviceSwift copied to clipboard
Receive disconnect notification but not "connected"
Hi, can you think of any reason why I can receive the disconnection notification but not the connected notification?
There's no errors whatsoever, I simply don't get the connected notification. I've tried a few different usb devices and all the same.
Using Swift 4 in High Sierra.
I've dug into the code and noticed the problem lies in here:
// USB device object is no longer needed.
IOObjectRelease(usbDevice)
// Dereference pointer for the plug-in interface
if (kr != kIOReturnSuccess) {
continue
}
It hits that continue
and never posts the notification.
If I comment that continue out, to see what happens, this happens:
Unable to get Plug-In Interface
So, upon further investigation, it stops working on 10.13 deployment target.
Works fine if I use older versions, though.
@nicholasamorim Reviving an old thread, but did you find a fix for this ?
@nicholasamorim Nevermind i found the answer after some serious head scratching. On Xcode 11, I had to tick the USB option on in the Project file > Targets > {APP NAME} > Sigining & Capabilities > App Sandbox
@fdidron it took you a year to respond to the first poster and now a year later, I am thanking you for your comment :)
@nicholasamorim Nevermind i found the answer after some serious head scratching. On Xcode 11, I had to tick the USB option on in the Project file > Targets > {APP NAME} > Sigining & Capabilities > App Sandbox
This should be added somewhere in the docs!
@fdidron so many thanks!
@sbilstein @txbrown monthes later I'm back at it and I'm running into the following issue on a M1 Mac. As soon as I add the App Sandbox entitlement to my application and run it, it crashes
Thread 1: EXC_BREAKPOINT (code=1, subcode=0x192b73110) in libsystem_secinit.dylib`_libsecinit_appsandbox.cold.5:
@fdidron hey sorry for the much late reply. I realised for me was easier to wrap libusb in a swift module and use that. took me way less time than fighting to understand this library without docs.