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

时间:2019-09-19 07:14:59

标签: ios xcode-storyboard ios13

在具有Xcode 11 GM种子2的iOS 13模拟器上,Main.storyboard的名称更改(Info.plist也更改)后,应用程序崩溃。将选项Main Interface设置为空会导致相同的问题。 iOS 13系统始终尝试找到Main.storyboard,但由于崩溃消息而失败:

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

在iOS 12和更低版本上一切正常。看起来像是iOS 13中的错误。

有人遇到相同的问题吗?还有解决方案吗?

2 个答案:

答案 0 :(得分:6)

使用iOS 13的Swift 5

  

应用程序下的 info.plist 文件中还需要进行其他更改   场景清单组。

enter image description here

也在应用场景清单中更改名称。

其他:
如果要在iOS13上没有情节提要的情况下创建根窗口,则需要从 Info.plist 中删除Main storyboard file base nameStoryboard Name项目,然后然后在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
    }

    //......
}

答案 1 :(得分:0)

在更改了Main storyboard file base name的名称之后,从Info.plist更改了Main.storyboard。当然,您也可以将其从General-Deployment info-{ {1}}。