1.新建項目(新建項目時請選擇如圖選項)
2.建完項目后搀继,不出問題的話能看到熟悉的Appdelegete回來了
那如何指定根控制器呢捧毛?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
if let windowScene = scene as? UIWindowScene {
let window = UIWindow(windowScene: windowScene)
window.rootViewController = UIHostingController(rootView: ContentView())
self.window = window
window.makeKeyAndVisible()
}
// guard let _ = (scene as? UIWindowScene) else { return }
}
ContentView 為你自己寫的swiftUI
到此工作完成 可以愉快的coding了