xcode UI窗口场景会话角色应用程序的信息列表配置“(无名称)”

ibps3vxo  于 2022-12-30  发布在  其他
关注(0)|答案(2)|浏览(123)

我收到以下警告,应用程序显示iOS 13黑屏

UIWindowSceneSessionRoleApplication的[场景配置] Info.plist配置“(无名称)”包含UISceneDelegateClassName键,但无法加载名为MyApp.SceneDelegate的类。
如何解决此问题?

f5emj3cl

f5emj3cl1#

SceneDelegate在iOS 13之后已受支持。如果您想使用SceneDelegate并且还想支持iOS 13之前的iOS,则必须在项目中进行一些更改。
如果iOS 13可用,则执行SceneDelegate

代码:

@available(iOS 13.0, *)

class SceneDelegate: UIResponder, UIWindowSceneDelegate {
   //Other code
}

@available(iOS 13.0, *)
func application(_ application: UIApplication, didDiscardSceneSessions sceneSessions: Set<UISceneSession>) {

}

在AppDelegate.swift中添加UIWindow对象

class AppDelegate: UIResponder, UIApplicationDelegate {    
    var window: UIWindow?
}

适用于iOS 12及更低版本

AppDelegate需要UIWindow属性。iOS 13在新项目中使用SceneDelegate。请指定UIWindow对象并移除SceneDelegate.swift文件。
如果已从项目中删除SceneDelegate,则必须从Info.plist中删除应用程序场景清单字典

4uqofj5v

4uqofj5v2#

如果除默认场景外未使用其他自定义场景,请从Info.plist中删除“UISceneClassName”。

<key>UISceneClassName</key>
<string></string>

相关问题