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
If you're missing Main. storyboard, it's probably because you forgot to change the User Interface setting to Storyboard when you created the project. If you leave it set to SwiftUI, then Main. storyboard doesn't get created.
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.
Step 2: Delete the Storyboard Your new project has been created, now navigate to the left side of your interface, select the “Main. storyboard” file in the main folder, left-click and hit delete.
Select Modeling > Storyboard from the toolbar. Right click on the storyboard to rename and select Rename Storyboard… from the popup menu. Click OK to confirm the new name.
open the info.plist of your project and remove the selected row displayed in screenshot
If you get a black screen ensure your new initial storyboard is selected as your main interface
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
3) Now go to info.plist and delete Storyboard Name
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
You may check the target membership of the storyboard. May be there is where the problem is:
It should be looking like this:
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.
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
.
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.
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"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With