Hi All, I would like to develop a small macOS app using swift. I want to use ImageCaptureCore to access and control connected scanners ( via usb). I followed the official docs and wrote this ScannerManager. The code seems to be working without issues or warnings.
I added the Hardened Runtime capability
and both com.apple.security.personal-information.photos-library
and com.apple.security.device.usb
to the .entitlements file.
As well added NSCameraUsageDescription
to the Info.plist
.
Problem: None of my scanners do get detected (tested 2 different models). Of course, they are connected and do get recognized by the Image Capture App (and work as expected) and are listed in the systems app, too. When I connect my phone it does get detected by the
func deviceBrowser(_ browser: ICDeviceBrowser, didAdd...
delegate function. Thats why I believe my code is working but the app is lacking permissions to detect scanners somehow. Does anyone know something about this?
I am using macOS 15.1.1 (24B91) on a M1 Pro.
Many thanks in advance!
class ScannerManager: NSObject, ICDeviceBrowserDelegate, ICDeviceDelegate {
let deviceBrowser: ICDeviceBrowser
private var currentDevice: ICDevice?
private var scannerDeviceDelegate: ScannerDeviceDelegate?
var isScanning = false
var scanners: [ICDevice] = []
// MARK: - Initialization
override init() {
print("🚀 Initializing ScannerManager...")
self.deviceBrowser = ICDeviceBrowser()
super.init()
self.deviceBrowser.delegate = self
// Log the initial browsed device type mask
self.deviceBrowser.browsedDeviceTypeMask = .scanner
print("🔍 Starting device browser...")
self.deviceBrowser.start()
// Enhanced device logging
if let devices = deviceBrowser.devices {
print("\n📱 Connected devices overview:")
print("Total devices found: \(devices.count)")
if devices.isEmpty {
print("⚠️ No devices currently connected")
} else {
devices.forEach { device in
print("\n📌 Device Details:")
print(" - Name: \(device.name ?? "unnamed")")
print(" - Type: \(String(describing: device.type))")
print(" - Transport Type: \(String(describing: device.transportType))")
print(" - Status: \(device.hasOpenSession ? "In Use" : "Available")")
print(" - Persistent ID: \(String(describing: device.persistentIDString))")
print(" - Location: \(device.locationDescription ?? "Unknown")")
print(" - Capabilities: \(String(describing: device.capabilities))")
}
}
} else {
print("⚠️ Unable to access device list")
}
}
...