Could not find a storyboard named 'Main' in bundle

前端 未结 24 1698
无人共我
无人共我 2020-12-01 00:26

I\'m getting a strange error: \'Could not find a storyboard named \'Main\' in bundle NSBundle\' when trying to run my app on a real iOS device.

I have

24条回答
  •  感情败类
    2020-12-01 01:20

    For anyone facing this issue on Xcode 11, here's how you fix it if you face this issue when doing storyboard less project setup

    (Adding some parts that ricardopereira missed)

    1) First, delete the Main.storyboard file

    2) Next, go to PROJECT_NAME -> GENERAL

    In main interface drop-down, delete the text Main

    3) Now go to info.plist and delete Storyboard Name

    4) Finally, modify scene(_:willConnectTo:options) code in the file SceneDelegate.swift (Yes! It's not in App Delegate anymore.)

    var window: UIWindow?
    
    
        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).
            guard let windowScene = (scene as? UIWindowScene) else { return }
            window = UIWindow(frame: windowScene.coordinateSpace.bounds)
            window?.windowScene = windowScene
            window?.rootViewController = ViewController()
            window?.makeKeyAndVisible()
        }
    

    You can also refer to this video instead: https://www.youtube.com/watch?v=Htn4h51BQsk

提交回复
热议问题