简体   繁体   English

无法在 iOS 13 [Xcode 11 GM 种子 2] 上更改 Main.storyboard 的名称

[英]Cannot change Main.storyboard's name on iOS 13 [Xcode 11 GM seed 2]

On iOS 13 simulator with Xcode 11 GM seed 2, the app crashes after Main.storyboard 's name changed (Info.plist changed also).在 iOS 13 模拟器和 Xcode 11 GM 种子 2 上,应用程序在Main.storyboard的名称更改后崩溃(Info.plist 也更改了)。 Setting option Main Interface to empty cause the same problem.将选项Main Interface设置为空会导致同样的问题。 The iOS 13 system always try to find the Main.storyboard , and failed with crashing message: iOS 13 系统总是试图找到Main.storyboard ,并失败并出现崩溃消息:

*** reason: 'Could not find a storyboard named 'Main' in bundle

Everything is fine on iOS 12 and earlier versions. iOS 12 及更早版本上一切正常。 It looks like a bug in iOS 13.它看起来像 iOS 13 中的一个错误。

Does anyone meet same problem?有没有人遇到同样的问题? And any solutions?以及任何解决方案?

Swift 5 with iOS 13 Swift 5 与 iOS 13

One more changes require in info.plist file under Application Scene Manifest group. Application Scene Manifest组下的info.plist文件中还需要进行一项更改。

在此处输入图像描述

Change name in Application Scene Manifest also.更改应用场景清单中的名称。

Additional:额外的:
If you want to create the root window without a storyboard on iOS13, you need removing the Main storyboard file base name and Storyboard Name item from Info.plist , and then create the window programmatically in SceneDelegate : If you want to create the root window without a storyboard on iOS13, you need removing the Main storyboard file base name and Storyboard Name item from Info.plist , and then create the window programmatically in SceneDelegate :

class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
        if #available(iOS 13.0, *) {
            //Do nothing here
        } else {
            window = UIWindow(frame: UIScreen.main.bounds)
            window?.makeKeyAndVisible()
        }

        return true
    }
}

class SceneDelegate: UIResponder, UIWindowSceneDelegate {

    var window: UIWindow?

    @available(iOS 13.0, *)
    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(windowScene: windowScene)
        // continue to create view controllers for window
    }

    //......
}

Change the Main storyboard file base name from Info.plist after you changed the name of Main.storyboard .And of course,you can change it from General - Deployment info - Main Interface .更改Main.storyboard的名称后,从Info.plist更改Main storyboard file base name 。当然,您可以从General - Deployment info - Main Interface更改它。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM