/startWithoutStoryboard

start xcode project without storyboard and XIB as Main Screen Xcode 11 Swift 5

Primary LanguageSwift

startWithoutStoryboard

start xcode project without storyboard and XIB as Main Screen Swift 5 xcode 11

Step

  • First Remove Main.storyboard
  • Remove reference to Main.storyboard from Deploy Info
    At general tab -> Deploy Info -> main interface field (delete and leave blank)
  • Remove the key Storyboard Name
    At info tab -> Application Scene Manifest (expand) -> Scene Configuration (expand) -> Application Session Role (expand) -> First Item
  • Add this code inside func scene SceneDelegate.swift
    this include navigationController
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        
        
    }

insert the following code

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

Replace MainScreenViewController() to your name of XIB file

  • And launch your app.