Xcode: Version 13.0 (13A233)
Swift: Version 5.5

创建新的项目后,项目默认使用的是Storyboard,现在想改用纯代码的方式

1.删除 Main Interface

路径: TARGETS -> General
Main Interface 中的值删除
去除Storyboard,改用纯代码_编写代码

2.删除 Storyboard Name

路径:Info -> Scene Configuration -> Application Session Role -> Storyboard Name
去除Storyboard,改用纯代码_纯代码_02

删除 Storyboard Name 这一项(点击减号删除)
去除Storyboard,改用纯代码_xcode_03

3.代码创建根控制器

路径:SceneDelegate
去除Storyboard,改用纯代码_swift_04

SceneDelegate 中的

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions)

编写代码创建方式

func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
    
    guard let _ = (scene as? UIWindowScene) else { return }
    
    guard let windowSence = (scene as? UIWindowScene) else { return }
    
    window = UIWindow(frame: windowSence.coordinateSpace.bounds)
    
    window?.windowScene = windowSence
    
    let navigationController = UINavigationController(rootViewController: NewsViewController())
    navigationController.navigationBar.prefersLargeTitles = true
    
    window?.rootViewController = navigationController
    window?.makeKeyAndVisible()
}