Static method 'buildBlock' requires that 'Bool' conform to 'View'

I want to check network reachability using Alamofire. This is the code:

var body: some Scene {

        WindowGroup {

            NetworkReachabilityManager()!.startListening { status in

                switch status {

                    case .notReachable, .unknown:

                        Text("No internet")

                            .bold()

                            .padding(.horizontal, 2)

                            .frame(maxWidth: .infinity)

                            .background(Color(hex: 0xce01e37))

                            .foregroundColor(Color.white)

                default : ()

                }

            }
            ...

But this error keeps showing:

Static method 'buildBlock' requires that 'Bool' conform to 'View'

Any solutions ?

In WindowsGroup, you need to have a View:

https://developer.apple.com/documentation/swiftui/scene

Such as:

struct MyScene: Scene {
    var body: some Scene {
        WindowGroup {
            MyRootView()
        }
    }
}

So, what does

NetworkReachabilityManager()!.startListening

return ? Probably a Bool ?

So you could embed

            NetworkReachabilityManager()!.startListening { status in

in a func that returns a View (such as Text("No internet") )

Static method 'buildBlock' requires that 'Bool' conform to 'View'
 
 
Q