Skip to content

Instantly share code, notes, and snippets.

@Myrrel
Last active March 10, 2024 21:52
Show Gist options
  • Save Myrrel/503f52edc4ffda27786d4a41b3d6a0bb to your computer and use it in GitHub Desktop.
Save Myrrel/503f52edc4ffda27786d4a41b3d6a0bb to your computer and use it in GitHub Desktop.
Removing Storyboard From App [Xcode 14, Swift 5]
// 1. Delete the Main.storyboard file from the project. Click Move to Trash.
// 2. Remove Storyboard Name from File info.plist
// 3. Go to Application Target -> Build Settings -> Find the line: UIKit Main Storyboard File Base Name and remove the name of the storyboard.
// 4. In order to programmatically set the root controller of our application:
// Go to SceneDelegate file and in the func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) method add the following code:
import UIKit
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(windowScene: windowScene)
let viewController = ViewController()
let navigation = UINavigationController(rootViewController: viewController)
window?.rootViewController = navigation
window?.makeKeyAndVisible()
}
func sceneDidDisconnect(_ scene: UIScene) {
}
func sceneDidBecomeActive(_ scene: UIScene) {
}
func sceneWillResignActive(_ scene: UIScene) {
}
func sceneWillEnterForeground(_ scene: UIScene) {
}
func sceneDidEnterBackground(_ scene: UIScene) {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment