I'm trying to use libusb in a macOS application with GUI. But I always fail with "No such module 'CLibUSB'". I could use CLibUSB in a command line application, but cannot get it to work with a macOS GUI application. What I did:
$ swift package init --type system-module
// swift-tools-version:5.1
import PackageDescription let package = Package( name: "Clibusb", pkgConfig: "libusb-1.0", providers: [ .brew(["libusb"]) ], dependencies: [ // Dependencies declare other packages that this package depends on // .package(url: /* package url */, from: "1.0.0"), ] )
echo '#include <libusb.h>' >shim.h
module CLibUSB [system] { header "shim.h" link "libusb-1.0" export * }
git init
git add .
git commit -m "Initial commit"
mkdir LibUSBExample cd LibUSBExample swift package init --type executable
How can I use CLibUsb in a GUI Application?
Download and copy libusb to your project folder from github.
Drag libusb.xcodeproj in libusb/Xcode into your project.
Create bridging header file :
#include "libusb.h"
Add header search path :

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With