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
Could not find a storyboard named 'Main' in bundle
提问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 Resources
section, the file Main.storyboard
is 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
回答by Geekoder
回答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
3) Now go to info.plist and delete Storyboard Name
3) 现在去 info.plist 并删除Storyboard Name
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 文件中的另一个条目。
- Open the info.plist file.
- Expand "Application Scene Manifest".
- Expand "Scene Configuration".
- Expand the item 0 under "Application Sessions Role" and then change the storyboard name there.
- 打开 info.plist 文件。
- 展开“应用场景清单”。
- 展开“场景配置”。
- 展开“Application Sessions Role”下的项目 0,然后在那里更改情节提要名称。
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
回答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:
解析度:
Selected the Main.storyboard file and tried to delete, and from the dialog that pops up as follows:
Clicked "Remove Reference" button.
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:
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.lproj
directory as follows: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.
Clean the Product, re-build, and if it is successful, most of the time try running it will be successful.
单击“删除引用”按钮。
然后,从我可以在项目目录中找到 Main.storyboard 文件的实际位置,拖放到 XCode 中,然后再次从弹出的对话框中,如下所示:
我选择了“创建文件夹引用”(因为这是我打算做的一件事,因为我更改了项目的文件和文件夹结构)。但大多数时候选择“创建组”也可能有效。并点击“完成”按钮。如屏幕截图所示,我的 Storyboard 文件已经在
Base.lproj
目录中,如下所示:注意:在这一步要提醒的一件重要事情是,不要忘记在您的应用程序的“添加到目标”复选框上打勾。
清理产品,重新构建,如果成功,大多数情况下尝试运行它会成功。
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
回答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是故事板名称