visionOS as a BLE peripheral: CBMutableService init unavailable

I'd like to have the visionOS be a peripheral, in BLE terminology. This is required, as the hardware that will act as the central cannot act as peripheral (don't ask).

The problem is some initializers I seem to need to advertise a mutable service are not available:

1. 'init(type:primary:)' has been explicitly marked unavailable here (CoreBluetooth.CBMutableService)

It would seem that this isn't supported yet. Is this currently possible some other way, or will it be possible in the future?

Answered by windurst in 777871022

Not sure if this was changed recently in the documentation, but it seems like this is by design:

https://developer.apple.com/documentation/corebluetooth/cbperipheralmanager says:

In watchOS, tvOS, and visionOS, you can’t advertise services using a CBPeripheralManager object because support for doing so is unavailable.

Looks like visionOS can only act as the central, or at the very least, cannot advertise services. I'm wondering if there is any way to work around this; I think advertising a service and acting as a peripheral are two orthogonal things, so if visionOS can act as a peripheral but just not advertise, I wonder if I can cobble together some odd solution.

At any rate, this was 'solved' with new hardware.

Can you have the visionOS in simulator as a BLE central? XPC connection fails when I start advertisement.

Accepted Answer

Not sure if this was changed recently in the documentation, but it seems like this is by design:

https://developer.apple.com/documentation/corebluetooth/cbperipheralmanager says:

In watchOS, tvOS, and visionOS, you can’t advertise services using a CBPeripheralManager object because support for doing so is unavailable.

Looks like visionOS can only act as the central, or at the very least, cannot advertise services. I'm wondering if there is any way to work around this; I think advertising a service and acting as a peripheral are two orthogonal things, so if visionOS can act as a peripheral but just not advertise, I wonder if I can cobble together some odd solution.

At any rate, this was 'solved' with new hardware.

visionOS as a BLE peripheral: CBMutableService init unavailable
 
 
Q