USB Device Notification failure in Xcode 10

Ref: From Apple's USBNotificationExample.c


The following line of code:

res = (*plugInInterface)->QueryInterface(plugInInterface, CFUUIDGetUUIDBytes(kIOUSBDeviceInterfaceID), (LPVOID *)&privateDataRef->deviceInterface);


Works fine in Xcode 9.4.1 but in Xcode 10.0 beta 6 I receive "couldn't create a device interface (80000004)" error message for all devices.


This issue occurs on macOS High Sierra 10.13.6.


Interestingly enough I do not have this issue on another machine running macOS Mojave 10.14 Beta 7 and Xcode 9.4.1 or Xcode 10.0 beta 6.

Accepted Reply

Apple got back to me on the 20th (sorry for the delay, have been dealing with a flooded basement):


September 20 2018, 10:40 PM

Engineering has the following feedback for you: You will need to specify a supported plugin interfaceID that is supported in the previous macOS’s. kIOUSBDeviceInterfaceID always uses the latest version which has API’s the early versions don’t have. You probably want to use kIOUSBDeviceInterfaceID650. Please see IOUSBLib.h for more details We are now closing this bug report. If you have questions or comments about the resolution, please update your bug report with that information so we can respond.


So it looks like we need to specify the version we're expecting explicitly so our code will run on older macOS versions. Which makes sense now in retrospect, but I'm also puzzled as to how any of my code ran before.

Replies

I'm having the same issue - software that runs fine when built w/ XCode 9.4 can't access USB devices when built w/ Xcode 10. I'm running the latest Xcode 10 (the GM) and the latest developer beta of Mojave as of today. Developing on 10.13.6 as well.


The code I'm building has been deployed successfully for several years on hundreds of thousands of Macs.


Maybe we could compare notes... I'll post anything new I can find.

It seems code built w/ XCode 10 GM only runs on 10.14, it won't run on 10.13 or 10.12.

I just tried Xcode 10 GM today and I'm still seeing the same issue.


I'll post anything new I can find here.

Tried signing the binary and turning on Capabilities->App Sandbox->Hardware->USB.


Tried turning off SIP.


Tried with Xcode 10 (10A255).


I noticed in Xcode 9.4.1 the default compiler is "Apple LLVM 9.0" but in Xcode 10 it's "Apple Clang". Not sure if that makes a difference?


Nothing so far has made a difference.

Apple got back to me on the 20th (sorry for the delay, have been dealing with a flooded basement):


September 20 2018, 10:40 PM

Engineering has the following feedback for you: You will need to specify a supported plugin interfaceID that is supported in the previous macOS’s. kIOUSBDeviceInterfaceID always uses the latest version which has API’s the early versions don’t have. You probably want to use kIOUSBDeviceInterfaceID650. Please see IOUSBLib.h for more details We are now closing this bug report. If you have questions or comments about the resolution, please update your bug report with that information so we can respond.


So it looks like we need to specify the version we're expecting explicitly so our code will run on older macOS versions. Which makes sense now in retrospect, but I'm also puzzled as to how any of my code ran before.

Thanks for taking the time to report back Apple's reponse. Changing kIOUSBDeviceInterfaceID to kIOUSBDeviceInterfaceID650 appears to have solved the issue for me. Thanks again!

Thanks for posting this! I needed to switch the call to use kIOUSBInterfaceInterfaceID650 (instead of "kIOUSBInterfaceInterfaceID"), but this at least gave me the clue of where to start looking.