在带有 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 中的错误。
有人遇到同样的问题吗?还有解决办法吗?
Swift 5 与 iOS 13
需要在 Application 下的 info.plist 文件中进行另一项更改 场景清单组。
还要更改应用程序场景清单中的名称。
补充:
如果您想在 iOS13 上创建没有 Storyboard 的根窗口,您需要从 Info.plist
中删除
Main storyboard file base name
和
Storyboard 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
}
//......
}
Main storyboard file base name
的名称后,将
Info.plist
更改为
Main.storyboard
。当然,您也可以将其更改为
General
-
Deployment info
-
Main Interface
。
Xcode 重命名 Main.storyboard
只需将UISceneStoryboardFile
字符串重命名为
Info.plist
文件中的正确字符串