Detect the number of USB ports available on the Mac device

I'm building a Swift based app for macOS. And I would like to know how many usb ports are available, for the device. For example, I have a MBP 13" with 4 usb ports. Two on the left, two on the right. The new MBP 14" has two on the left and one on the right. And then, I would like to know where a connected USB flash drive is connected to. For example: First USB port on the left side.

I have the code for detected what disks are connected in place. I also get the events for when new devices are connected, and disconnected. This code works already.

Now I want to know, whether I can detect whether the USB device is connected to the first USB port left for example.

I checked DriverKit, AppKit, UIKit, and whatever I could find, but without any hints. (Maybe it is possible via Objective-C/C?)

Hi. This forum is specifically about the Swift language itself. Apple have asked that questions like yours (about macOS frameworks etc…) should be asked at the their developer forums. Or I’d recommend Stack Overflow.

I suspect there’s no API to let you know which side of a machine a port is on however.