简体   繁体   English

从 .xcodeproj 切换到 .xcworkspace 后无法实例化默认视图控制器

[英]Failed to instantiate the default view controller after switching from .xcodeproj to .xcworkspace

When I create a brand new project in Xcode and choose Storyboard for the interface, I can run the app on my phone just fine.当我在 Xcode 中创建一个全新的项目并为界面选择 Storyboard 时,我可以在手机上运行该应用程序。

However, when I do pod install (the only deps I added are pod 'Plaid' ) and then switch over to the .xcworkspace file, I get this error:但是,当我执行pod install (我添加的唯一 deps 是pod 'Plaid' )然后切换到 .xcworkspace 文件时,我收到此错误:

[WindowScene] Failed to instantiate the default view controller for UIMainStoryboardFile 'Main' - perhaps the designated entry point is not set?

I have tried the usual fixes (check Is Initial View Controller etc.)我已经尝试了通常的修复(检查是初始视图控制器等)

Appreciate any help, thanks.感谢任何帮助,谢谢。

You must assign entry point to your project, go to your sceneDelegate file and set it like this:您必须为您的项目分配入口点,转到您的 sceneDelegate 文件并将其设置如下:

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)
    window?.backgroundColor = .white // or the color that you prefer
    window?.makeKeyAndVisible()
    let controller = ViewController() // or the first controller presented in your app
    window?.rootViewController = controller
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法实例化UIMainStoryboardFile'Main'的默认视图控制器 - Failed to instantiate the default view controller for UIMainStoryboardFile 'Main' 如何清除“无​​法实例化默认视图控制器”警告? - How to remove “Failed to instantiate the default view controller” warning? 无法实例化默认视图控制器? - cannot instantiate default view controller? 无法为 UIMainStoryboardFile 'Main' 实例化默认视图 controller - 也许未设置指定的入口点? - Failed to instantiate the default view controller for UIMainStoryboardFile 'Main' - perhaps the designated entry point is not set? 未能为 UIMainStoryboardFile 'Main' 实例化默认视图 controller - 也许未设置指定的入口点? - Failed to instantiate the default view controller for UIMainStoryboardFile 'Main' - perhaps the designated entry point is not set? 无法实例化视图控制器。 - 斯威夫特 - Failed to instantiate view controller. - Swift CocoaPods Google Analytics .xcworkspace和.xcodeproj文件 - CocoaPods Google Analytics .xcworkspace and .xcodeproj files 避免用户意外打开 Xcodeproj 而不是 Xcworkspace - Avoiding users accidentally opening Xcodeproj instead of Xcworkspace 切换到View Controller B后如何保持View Controller A的状态? - How to keep state of View Controller A after switching to View Controller B? 使用后代类从Storyboard实例化视图控制器 - Instantiate view controller from Storyboard with a descendant class
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM