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.
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.
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:
/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
https://i.stack.imgur.com/M90iH.png
https://i.stack.imgur.com/65P0S.png
For 2021...
You must also edit UIApplicationSceneManifest
. See the more recent answers below.
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
https://i.stack.imgur.com/PJwOw.png
3) Now go to info.plist and delete Storyboard Name
https://i.stack.imgur.com/Xe2LY.png
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
guard let _ = (scene as? UIWindowScene) else { return } let viewController = ViewController() if let windowScene = scene as? UIWindowScene { self.window = UIWindow(windowScene: windowScene) self.window?.rootViewController = viewController self.window?.makeKeyAndVisible() }
You may check the target membership of the storyboard. May be there is where the problem is:
It should be looking like this:
https://i.stack.imgur.com/3i4TU.png
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.
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.
https://i.stack.imgur.com/vNe7D.png
And your application will start working.
In a project that uses UIScene
in iOS 13 and Xcode 11, you need to remove the UISceneStoryboardFile
key from the .plist
.
Xcode 11:
https://i.stack.imgur.com/WtAmm.png
Changing directly from the file:
https://i.stack.imgur.com/AHmQB.png
I deleted the app from my phone, did Product-->Clean, and loaded it again. That's all it took for me.
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.
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:
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.
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!
Follow the steps:
1) First Click your story board
2) Then Click File Inspector
3) Then select "Target Membership"
https://i.stack.imgur.com/3qxHW.png
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
Swift 5.1 & xCode 11.2
In my case, I forgot to change Storyboard Name
in Info.plist
https://i.stack.imgur.com/Z48UN.png
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>
Also, try removing the Storyboard name
https://i.stack.imgur.com/PGLlb.png
Open you storyboard file Then Click File Inspector Then select "Target Membership" and check your project Do the same for ViewController file !!!important part if you use ViewController.swift or ViewController.m with your storyboard!!!
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).
https://i.stack.imgur.com/RTCQk.png
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.
Deleting row in plist caused black screen in my app too. And I fixed it by enabling target membership of the storyboard
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.
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()
choose main.storyboard, change the view as iOS 6.1 and earlier, then xcode will tell u what u need to do.
https://i.stack.imgur.com/PfLjW.png
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 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
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.
https://i.stack.imgur.com/k9lzk.png
https://i.stack.imgur.com/v5yrx.png
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)
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 !!!
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.
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
Success story sharing