I'm trying to use Bluetooth in a SwiftUI on Playgrounds. I have a running sample using UIKit, but with SwiftUI, I ran into an interesting problem.
I startet with the empty App-Sample and defined the ContentView like this:
import SwiftUI
struct ContentView: View {
var body: some View {
VStack {
Text("Hello, world!")
Button {
print("hello")
} label: {
Text("press me")
}.buttonStyle(.bordered)
}
}
}
The MyApp-code looks like this
import SwiftUI
import PlaygroundSupport
import PlaygroundBluetooth
@main
struct MyApp: App {
//private var centralManager: PlaygroundBluetoothCentralManager?
var body: some Scene {
WindowGroup {
ContentView()
}
}
}
With this implementation, I can click on the Button and it prints the message.
But if I uncomment the private var centralManager, the App does not run anymore.
Any ideas? Thanks in advance
Rainer