升级Xcode 14.2后出现Info.plist无UIScene配置字典错误求解决
解决Xcode 14.2升级后Info.plist的UIScene配置错误
问题根源
Xcode 14.2对iOS应用的Scene配置校验逻辑更严格,老版纯UIKit项目(未适配SceneDelegate架构)或Info.plist配置不规范时,容易触发该错误。可视化编辑界面找不到UIScene相关选项,是因为项目未启用Scene配置的关联模块,直接编辑源码即可绕过这个限制。
具体解决方案
直接编辑Info.plist源码(推荐)
右键点击项目中的Info.plist文件,选择Open As -> Source Code,在根<dict>标签内添加以下配置:<key>UIApplicationSceneManifest</key> <dict> <key>UISceneConfigurations</key> <dict> <key>UIWindowSceneSessionRoleApplication</key> <array> <dict> <key>UISceneConfigurationName</key> <string>Default Configuration</string> <key>UISceneDelegateClassName</key> <string>$(PRODUCT_MODULE_NAME).SceneDelegate</string> </dict> </array> </dict> </dict>若项目没有SceneDelegate文件,可新建一个基础版本:
import UIKit class SceneDelegate: UIResponder, UIWindowSceneDelegate { var window: UIWindow? func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) { guard let windowScene = (scene as? UIWindowScene) else { return } window = UIWindow(windowScene: windowScene) window?.rootViewController = UIViewController() // 替换成你的根控制器 window?.makeKeyAndVisible() } }老项目跳过Scene架构适配
若不想适配Scene架构,可在Info.plist源码中添加以下配置,强制使用传统AppDelegate模式:<key>UIApplicationSupportsMultipleScenes</key> <false/> <key>UIMainStoryboardFile</key> <string>Main</string>注意:确保
UIMainStoryboardFile的值和项目中实际的故事板文件名一致。校验Info.plist路径配置
进入target的Info选项卡,检查Custom iOS Target Properties顶部的Info.plist路径是否正确,路径需指向与.xcodeproj同目录的Info.plist文件,示例路径:$(SRCROOT)/YourProjectName/Info.plist
内容的提问来源于stack exchange,提问作者user20439709
相关产品推荐
相关产品推荐

