Is it possible to migrate an old Xcode project to use SwiftUI?

后端 未结 3 1057
梦如初夏
梦如初夏 2020-12-08 21:11

I have an app made in Xcode 10 using Main.storyboard and would like to migrate it to use Apple\'s new framework: SwiftUI.
Is that already possible?

I have alrea

3条回答
  •  既然无缘
    2020-12-08 21:36

    It's a correct only minor change

    In SceneDelegate.swift replace

    let window = UIWindow(frame: UIScreen.main.bounds)
    window.rootViewController = UIHostingController(rootView: ContentView())
    self.window = window
    window.makeKeyAndVisible()
    

    with

    if let windowScene = scene as? UIWindowScene {
        let window = UIWindow(windowScene: windowScene)
        window.rootViewController = UIHostingController(rootView: ContentView())
        self.window = window
        window.makeKeyAndVisible()
    }
    

    TAKEN FROM HERE

提交回复
热议问题