SDP query callback runs on macOS Big Sur but not Ventura

I have the following Swift code to perform an SDP query on a remote device:

import IOBluetooth

class Callback: IOBluetoothDeviceAsyncCallbacks {
  func sdpQueryComplete(_ device: IOBluetoothDevice!, status: IOReturn) {
    print("Query complete")
    CFRunLoopStop(CFRunLoopGetCurrent())
  }

  func connectionComplete(_ device: IOBluetoothDevice!, status: IOReturn) {}

  func remoteNameRequestComplete(_ device: IOBluetoothDevice!, status: IOReturn) {}
}

let callback = Callback()
let device = IOBluetoothDevice(addressString: "3c:61:05:2a:ed:12")
let uuid = IOBluetoothSDPUUID(uuid16: 0x0003)

let result = device!.performSDPQuery(_: callback, uuids: [uuid!])
print("Query started, result \(result)")
CFRunLoopRun()

On my 2021 MacBook Pro (with Ventura 13.1), the code prints "Query started, result 0" and hangs indefinitely because the callback does not run to stop the loop. However, on a virtual machine with Big Sur 11.3, the code also prints "Query complete" and exits normally.

I believe this issue is related to other Bluetooth issues that have existed since Monterey, which have been posted about before.

Since I plan to use SDP queries in my own application, are there any solutions or workarounds to make the above code work on recent versions of macOS?

performSDPQuery() without specifying uuids works for me, with uuids I can observe the same behaviour even on Sonoma.

SDP query callback runs on macOS Big Sur but not Ventura
 
 
Q