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

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

我的目录中有这个文件,它在模拟器中工作得很好。但是,在 Copy Bundle Resources部分中,文件 Main.storyboard是红色的。

我试过删除它并重新添加它,重新启动 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
127499 次浏览

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

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

For 2021...

You must also edit UIApplicationSceneManifest. See the more recent answers below.

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

choose main.storyboard, change the view as iOS 6.1 and earlier, then xcode will tell u what u need to do.

enter image description here

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.

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

main.storyboard -> only main is the storyboard name

Deleting row in plist caused black screen in my app too. And I fixed it by enabling target membership of the storyboard

My solution is:

When i added a Seque Connection between two Views and in the Projekt Configuration the Deployment Target is less then 8.0 i get this error.

ok, easy understanding when you develop for IOS 6.0 (for example) you can't use Seque, because the Seque needs IOS 8.0 or later...... ;-)

so, i set the Deployment Target to 8.0 and the error is gone !!!! other while, i cancel all the Segue Connections and handle it with IBAction, old school ;-)

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

Ok this has been a process. Trying so many different things. Running xcode 6.4 on OS 10.11. Having the cannot find 'Main' problem. What I finally did was move the main.storyboard off on too my desktop from Finder.Did a clean and build and quit xcode. restarted xcode now it has a red main.storyboard. i run it virtually does the same thing. then I right click on the project folder and choose the option add files to... Browse to where it is and open it. then when it is there to the right should be the identities inspector. click on the small folder under location. browse to that folder again and select choose. Then I ran and it worked. Amen !!!

Could not find a storyboard named 'Main' in bundle

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.

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.lproj directory 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.

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!

I was moving Main.Storyboard file to "blue" sub folder which was causing issues, I had to add sub folders following these instructions Xcode 6.3 New File Issue

then moving Main.Storyboard file to yellow sub folder did work for me

Follow the steps:

1) First Click your story board

2) Then Click File Inspector

3) Then select "Target Membership"

Screen Shot

As Kalpit Gajera has said, "open the info.plist of your project and remove the selected row displayed in screenshot". You simply remove 'Main storyboard file base name' from the Info.plist. After you remove it, clean and run, the program will no longer fail but will show a black screen. Open Info.plist again and manually add the row back in. Problem solved.

  1. Open you storyboard file
  2. Then Click File Inspector
  3. Then select "Target Membership" and check your project
  4. Do the same for ViewController file !!!important part if you use ViewController.swift or ViewController.m with your storyboard!!!

Two different solutions that worked for me after upgrading to Xcode 10.1:

  • In File->Workspace (or Project) Settings. Switch to Legacy Build System.

  • In your targets Build Phases, remove the Base.lproj folder from Copy Bundle Resources (if listed) and make sure each of your storyboards are listed and copied separately instead.

After applying either of the fixes above make sure you Clean Build Folder from the Product menu once, otherwise the fixes might not work properly.

My issue was resolved by removing the .xml suffix from the Main.storyboard.xml file.

Apparently, the suffix changed from the version from which I imported the project.

Therefore, renaming the file (removing the .xml suffix) and restarting, then Project-> clean.... fixed the problem.

In a project that uses UIScene in iOS 13 and Xcode 11, you need to remove the UISceneStoryboardFile key from the .plist.

Xcode 11:

xcode11-uiscene

Changing directly from the file:

uiscene-plist

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

(Adding some parts that ricardopereira missed)

1) First, delete the Main.storyboard file

2) Next, go to PROJECT_NAME -> GENERAL

In main interface drop-down, delete the text Main

removing reference to main from general settings

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

removing reference to the storyboard from info.plist

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

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

Swift 5.1 & xCode 11.2

In my case, I forgot to change Storyboard Name in Info.plist

enter image description here

Info.plist source code

    <dict>
<key>UIApplicationSupportsMultipleScenes</key>
<false/>
<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>
<key>UISceneStoryboardFile</key>
<string>AccountViewController</string>
</dict>
</array>
</dict>
</dict>

An update for applications created for iOS 13.0 and above. (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.

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

  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.

enter image description here

And your application will start working.

Select the view controller you want to first show up in the list on the left side of the storyboard, then in the attribute inspector make sure its title is "Main" and the checkbox for "Is Initial View Controller" is selected.

This error come, while you recover your main.storyboard file from trash after delete your file. I also faced same issue yesterday.

You have to set the location path of the main.storyboard as Relative to Group in file inspector of main.storyboard. After that in the same attribute, you have to insure the check mark on your app target(As you can see in attached picture).

enter image description here

If still you have black screen, then try adding below code in your scene delegate

willConnectTo

    guard let windowScene = (scene as? UIWindowScene) else { return }
window = UIWindow(frame: windowScene.coordinateSpace.bounds)
window?.windowScene = windowScene
let navController = UINavigationController()
let mainstoryboard:UIStoryboard = UIStoryboard(name: "Your storyboard name", bundle: nil)
let initialController = mainstoryboard.instantiateViewController(withIdentifier: "your initial controller Identifier") as! initialController
navController.addChild(initialController)
window?.rootViewController = navController
window?.makeKeyAndVisible()

If your storyboard is added in project (which you'll determine from Project File Inspector section of xcode utility area)Check box is marked in target membership area

You just have to remove Main.Storyboard from "Copy bundle resource" (in Build Phase) and add it again in "Copy bundle resource". This was worked for me.enter image description here

Also, try removing the Storyboard name

enter image description here

In my case this was due to a Pod library that was outdated

Deleting the /Pods folder and doing pod install fixed it for me

Note: If some ViewControllers are missing "Could not find a storyboard named 'ReceiverViewController' in bundle" you can add the name of ViewController in storyBoard id and use the code below for navigation

let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let vc = storyBoard.instantiateViewController(withIdentifier: "ReceiverViewController") as! ReceiverViewController
self.navigationController?.pushViewController(vc, animated: true)

For my project named ZHE Admin I changed name of the main storyboard to home. Other than changing it in info.plist file, I had to change it in the build settings like shown in the screenshot here.

enter image description here

New in Xcode 14, setting the Main Interface has moved to Targets -> Build Settings -> Info.plist values -> UIKit Main Storyboard File Base Name. You'll need to remove the reference from here instead of under the Deployment Info like before.

If your xcode version is 14.0.1 or higher, enter image description here

Delete the name in 'UIKit Main Storyboard File Base Name' shown in the picture.

enter image description here Target -> Info -> Main storyboard file base name value should be deleted.

I hope this helps.

In XCode 14.1, If you do not want to use Main.StoryBoard and deleted it, then see image and Remove "Main" at step-4.

If you have added a Main Story Board Then write "Main" at Step-4. This Image is showing you how you can resolve this Main problem