Detecting hardware keyboard key press under iPadOS 14.x with SwiftUI 2.0

199 views Asked by At

i'm trying to add hardware keyboard support for an iOS 14.0 app written in SwiftUI 2.0. I saw some examples working with UIHostingController, so i'd like to try this way on iOS14/SWiftui 2.0 using WindowGroup.

I'm gettin gerror when compiling in XCODe 12.3 "Generic struct 'WindowGroup' requires that 'KeyTestController' conform to 'View'"

ContentView() conforms to View and everything is working fine when not using the "KeyTestController" class.

Any way to solve this ?

Thank you very much.

import SwiftUI
import StoreKit
import UIKit

@main
struct myApp: App
{
    var body: some Scene
    {
        WindowGroup
        {
            KeyTestController(rootView:ContentView())
        }
    }
}

class KeyTestController<Content>: UIHostingController<Content> where Content: View
{
 /* CODE …… */
}
0

There are 0 answers