无法更改 Main.storyboard 在 iOS 13 [Xcode 11 GM seed 2] 上的名称
Cannot change Main.storyboard's name on iOS 13 [Xcode 11 GM seed 2]
在 iOS 13 模拟器和 Xcode 11 GM 种子 2 上,应用程序在 Main.storyboard
的名称更改后崩溃(Info.plist 也更改)。将选项 Main Interface
设置为空会导致同样的问题。 iOS 13 系统总是试图找到 Main.storyboard
,但失败并显示崩溃消息:
*** reason: 'Could not find a storyboard named 'Main' in bundle
在 iOS 12 和更早版本上一切正常。 它看起来像是 iOS 13 中的错误。
有没有人遇到同样的问题?有什么解决办法吗?
把Main.storyboard
的名字改成Info.plist
,再把Main storyboard file base name
改成Main.storyboard
。当然,你也可以从General
-Deployment info
改成-Main Interface
.
Swift 5 与 iOS 13
One more changes require in info.plist file under Application
Scene Manifest group.
在应用程序场景清单中也更改名称。
补充:
如果要在 iOS13 上创建没有故事板 的根 window ,则需要从中删除 Main storyboard file base name
和 Storyboard Name
项目Info.plist,然后在 SceneDelegate
:
中以编程方式创建 window
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
}
//......
}
在 iOS 13 模拟器和 Xcode 11 GM 种子 2 上,应用程序在 Main.storyboard
的名称更改后崩溃(Info.plist 也更改)。将选项 Main Interface
设置为空会导致同样的问题。 iOS 13 系统总是试图找到 Main.storyboard
,但失败并显示崩溃消息:
*** reason: 'Could not find a storyboard named 'Main' in bundle
在 iOS 12 和更早版本上一切正常。 它看起来像是 iOS 13 中的错误。
有没有人遇到同样的问题?有什么解决办法吗?
把Main.storyboard
的名字改成Info.plist
,再把Main storyboard file base name
改成Main.storyboard
。当然,你也可以从General
-Deployment info
改成-Main Interface
.
Swift 5 与 iOS 13
One more changes require in info.plist file under Application Scene Manifest group.
在应用程序场景清单中也更改名称。
补充:
如果要在 iOS13 上创建没有故事板 的根 window ,则需要从中删除 Main storyboard file base name
和 Storyboard Name
项目Info.plist,然后在 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
}
//......
}