I'm developing an app which supports for connect with an BLE device. There are some views for showing data from bluetooth. The code below for an example:
@EnvironmentObject var bleManager: BLEManager // a class implemented CBCentralManagerDelegate
var body: some View {
// bleConnected is a CBPeripheral
if let bleConnected = bleManager.bleConnected {
if let services = bleConnected.services {
ForEach(services, id:\.self) { service in
// UI for print uuid, descriptions ...
showServiceDescriptionView(services)
if let characteristics = service.characteristics {
ForEach(characteristics, id:\.self) { characteristic in
// UI for print uuid, data for each characteristic
showCharacteristicsDetailView(characteristic)
}
}
}
}
}
}
}
But it seems that Xcode Preview do not support connect to a real bluetooth device. So the preview window in Xcode will always be a empty view. I only can see the data on the real device. But it's important for me to design UI on the preview. So are there any method to mock a fake CBPeripheral in the Previewer? Or are there any other way to achieve this?