ios 在捆绑包中找不到名为“Main”的故事板

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/19240054/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 02:11:31  来源:igfitidea点击:

Could not find a storyboard named 'Main' in bundle

iphoneiosobjective-cxcode

提问by Carpetfizz

I'm getting a strange error: 'Could not find a storyboard named 'Main' in bundle NSBundle'when trying to run my app on a real iOS device.

我收到一个奇怪的错误:'Could not find a storyboard named 'Main' in bundle NSBundle'尝试在真正的 iOS 设备上运行我的应用程序时。

I have the file in my directory, and it works fine in the simulator. However, in the Copy Bundle Resourcessection, the file Main.storyboardis red.

我的目录中有该文件,它在模拟器中运行良好。但是,在该Copy Bundle Resources部分中,该文件Main.storyboard是红色的。

I've tried removing it and adding it again, restarting Xcode, cleaning build, etc. with no avail. This is the warning I get in Xcode:

我试过删除它并再次添加它,重新启动 Xcode,清理构建等,但无济于事。这是我在 Xcode 中得到的警告:

/Users/ajay/Documents/avx/avx/Base.lproj/Main.storyboard: Internationalization of /Users/ajay/Documents/avx/avx/Base.lproj/Main.storyboard is not available when compiling for targets before iOS 6.0

回答by Kalpit Gajera

open the info.plist of your project and remove the selected row displayed in screenshotenter image description here

打开项目的 info.plist 并删除屏幕截图中显示的选定行在此处输入图片说明

If you get a black screen ensure your new initial storyboard is selected as your main interface enter image description here

如果出现黑屏,请确保选择新的初始故事板作为主界面 在此处输入图片说明

回答by Geekoder

You may check the target membership of the storyboard. May be there is where the problem is:

您可以检查故事板的目标成员资格。可能是哪里出了问题:

It should be looking like this:

它应该是这样的:

Target Membership

目标会员

回答by Parth Tamane

For anyone facing this issue on Xcode 11, here's how you fix it if you face this issue when doing storyboard less project setup

对于在 Xcode 11 上遇到此问题的任何人,如果您在进行 Storyboardless 项目设置时遇到此问题,您可以通过以下方法解决此问题

(Adding some parts that ricardopereiramissed)

(补充一些ricardopereira漏掉的部分)

1) First, delete the Main.storyboard file

1)首先,删除Main.storyboard文件

2) Next, go to PROJECT_NAME-> GENERAL

2) 接下来,转到PROJECT_NAME-> GENERAL

In main interface drop-down, delete the text Main

在主界面下拉菜单中,删除文字Main

removing reference to main from general settings

从一般设置中删除对 main 的引用

3) Now go to info.plist and delete Storyboard Name

3) 现在去 info.plist 并删除Storyboard Name

removing reference to the storyboard from info.plist

从 info.plist 中删除对故事板的引用

4) Finally, modify scene(_:willConnectTo:options)code in the file SceneDelegate.swift(Yes! It's not in App Delegate anymore.)

4)最后,修改场景(_:willConnectTo:选项)在文件中的代码SceneDelegate.swift!(是的,这不是在应用代表了)。

var window: UIWindow?


    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(frame: windowScene.coordinateSpace.bounds)
        window?.windowScene = windowScene
        window?.rootViewController = ViewController()
        window?.makeKeyAndVisible()
    }

You can also refer to this video instead: https://www.youtube.com/watch?v=Htn4h51BQsk

你也可以参考这个视频:https: //www.youtube.com/watch?v=Htn4h51BQsk

回答by Shubham

An update for applications created for iOS 13.0 and above. (Xcode 11)

为 iOS 13.0 及更高版本创建的应用程序的更新。(Xcode 11)

If you get the error "Could not find a storyboard named 'Main' in bundle even after changing the "Main storyboard File base name" in the info.plist and "Main Interface" under Deployment in Target.

如果您收到错误“即使更改了 info.plist 中的“主故事板文件基本名称”和 Target 中部署下的“主界面”,也无法在包中找到名为“Main”的故事板。

Then you have to change another entry in the info.plist file.

然后您必须更改 info.plist 文件中的另一个条目。

  1. Open the info.plist file.
  2. Expand "Application Scene Manifest".
  3. Expand "Scene Configuration".
  4. Expand the item 0 under "Application Sessions Role" and then change the storyboard name there.
  1. 打开 info.plist 文件。
  2. 展开“应用场景清单”。
  3. 展开“场景配置”。
  4. 展开“Application Sessions Role”下的项目 0,然后在那里更改情节提要名称。

enter image description here

在此处输入图片说明

And your application will start working.

您的应用程序将开始工作。

回答by user1021430

I deleted the app from my phone, did Product-->Clean, and loaded it again. That's all it took for me.

我从手机中删除了该应用程序,执行了 Product--> Clean,然后重新加载了它。这就是我所需要的。

回答by kraftydevil

I got this error, however, it was my intention to remove storyboards completely.

我遇到了这个错误,但是,我打算完全删除故事板。

Removing the 'Main Storyboard file base name' key from my plist cured the error.

从我的 plist 中删除 'Main Storyboard file base name' 键修复了错误。

回答by ricardopereira

In a project that uses UIScenein iOS 13 and Xcode 11, you need to remove the UISceneStoryboardFilekey from the .plist.

UISceneiOS 13 和 Xcode 11中使用的项目中,您需要UISceneStoryboardFile.plist.

Xcode 11:

Xcode 11:

xcode11-uiscene

xcode11-uiscene

Changing directly from the file:

直接从文件更改:

uiscene-plist

uiscene-plist

回答by Randika Vishman

Could not find a storyboard named 'Main' in bundle

在捆绑包中找不到名为“Main”的故事板

Reason I could think of:

我能想到的原因:

As far as my iOS knowledge concluded me, this was just happened because the XCode was unable to find the reference to the Main.storyboard file within my project directory to copy it into the App.

就我的 iOS 知识得出的结论而言,这只是因为 XCode 无法在我的项目目录中找到对 Main.storyboard 文件的引用以将其复制到应用程序中。

Resolution:

解析度:

  1. Selected the Main.storyboard file and tried to delete, and from the dialog that pops up as follows: enter image description here

  2. Clicked "Remove Reference" button.

  3. Then, from the actual place where I could find the Main.storyboard file within the project directory, dragged, and dropped to the XCode, and again from the dialog that pops up as follows: enter image description here

  4. I choosed, "Create folder references" (because that's one thing I intended to do because I've changed my project's file and folder structure). But most of the times choosing "Create groups" also might work. And clicked on "Finish" button. My Storyboard files were already within as shown in the screenshot already within a Base.lprojdirectory as follows:

    enter image description here

    Note:One important thing to remind here at this step is, don't forget to tick it ON the checkbox "Add to targets" to your app.

  5. Clean the Product, re-build, and if it is successful, most of the time try running it will be successful.

  1. 选择了Main.storyboard文件并尝试删除,从弹出的对话框中如下: 在此处输入图片说明

  2. 单击“删除引用”按钮。

  3. 然后,从我可以在项目目录中找到 Main.storyboard 文件的实际位置,拖放到 XCode 中,然后再次从弹出的对话框中,如下所示: 在此处输入图片说明

  4. 我选择了“创建文件夹引用”(因为这是我打算做的一件事,因为我更改了项目的文件和文件夹结构)。但大多数时候选择“创建组”也可能有效。并点击“完成”按钮。如屏幕截图所示,我的 Storyboard 文件已经在Base.lproj目录中,如下所示:

    在此处输入图片说明

    注意:在这一步要提醒的一件重要事情是,不要忘记在您的应用程序的“添加到目标”复选框上打勾。

  5. 清理产品,重新构建,如果成功,大多数情况下尝试运行它会成功。

Hope this might be helpful to somebody else out there! I tried this on XCode 7.3.1 and on iOS Sim 9.3 and iPhone 6S!

希望这可能对其他人有帮助!我在 XCode 7.3.1 和 iOS Sim 9.3 和 iPhone 6S 上试过这个!

回答by Vicky

Follow the steps:

按照步骤:

1) First Click your story board

1) 首先点击你的故事板

2) Then Click File Inspector

2)然后单击文件检查器

3) Then select "Target Membership"

3)然后选择“目标会员”

Screen Shot

截屏

回答by Vicky

The simulator is not case sensitive, but the device is. If your storyboard is called MainStoryboard, not MainStoryBoard, this will cause your problem. and aslo * dont use the extensions write only the story board name

模拟器不区分大小写,但设备区分大小写。如果您的故事板被称为 MainStoryboard,而不是 MainStoryBoard,这将导致您的问题。并且 * 不要使用扩展名只写故事板名称

main.storyboard -> only mainis the storyboard name

main.storyboard -> 只有main是故事板名称