scanForPeripheralsWithServices on Monterey requires services array

I have a bundle that I created that I then distribute with a test app.

Before Monterey it has worked fine.

On Monterey (Intel or Apple Silicon) it stopped returning scan results. I do not get any errors it just doesn't ever call the didDiscoverPeripheral like it used it.

If I make the single change of passing in an array of Service UUID values then suddenly it will find that one device and return scan results.

My bundle and app need to support scanning for all peripherals.

Can someone help me fix this?

I'm encountering the same problem! I publish a general-purpose BLE survey tool that many folks find useful for development. https://github.com/jnross/Bluetility. It is essential that this tool can scan for any advertising peripheral and not need to specify an advertised service UUID. This issue doesn't seem to be directly caused by Monterey because old builds continue to work. So it seems that instead this is caused by either Xcode 13 or the macOS SDK included with Xcode13.

I filed an Apple Developer Technical Support ticket about this. If I'm able, I'll share what I learn here.

I'm found a simple fix for this issue. I found it not through any error messages or other debugging techniques; but by making an example project.

In the sample project, scanning with a nil serviceUUIDs argument behaves as expected! By process of elimination and applying changes to this project, I figured out that the bug only occurs when code signing is omitted. It's baffling to me that this subtle difference in API behavior would vary based on whether the code is signed or not. But, I'm happy to find a fix.

Here is the PR with the fix as applied to my project: https://github.com/jnross/Bluetility/pull/20/files

And screenshots showing before and after the fix. Notice the difference in "Signing Certificate" as "None" vs "Sign to Run Locally"

Before:

After:

scanForPeripheralsWithServices on Monterey requires services array
 
 
Q