117

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
Remi Guan
  • 21,506
  • 17
  • 64
  • 87
Carpetfizz
  • 8,707
  • 22
  • 85
  • 146
  • I described how to solve the problem inside this post: http://stackoverflow.com/a/21098195/1141395 – Alex Cio Jan 13 '14 at 18:06
  • This issue mainly happens because of corrupt app installation. The solution is to clean and build the project. Also remove the existing app from device/simulator and run again. – Krishnabhadra Nov 05 '15 at 07:14
  • **Xcode 11** users, scroll down to the https://stackoverflow.com/a/58452686 , possibly it's exactly your case. – Cemen Jan 05 '20 at 10:59

31 Answers31

128

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.

Fattie
  • 27,874
  • 70
  • 431
  • 719
Kalpit Gajera
  • 2,475
  • 1
  • 14
  • 24
  • 28
    Thanks, but this just made my app launch with a black screen. No crashes though. – Carpetfizz Oct 08 '13 at 15:07
  • 1
    Make sure to have these two lines in your - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions...: (1) self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]]; (2) self.window.backgroundColor = [UIColor whiteColor]; – Joel Hansen May 30 '14 at 16:53
  • @ Carpetfizz Add '[self.window makeKeyAndVisible];' to your AppDelegate. – Alserda Apr 16 '15 at 10:16
  • 5
    "app launch with a black screen", nobody has any idea for this? – Umit Kaya Apr 22 '16 at 09:59
  • 1
    @Umitk set the background to white (view.backgroundColor = .white) or any other color you like – Stephane Paquet Jul 25 '19 at 18:18
  • If you get black screen - note that with Xcode 11 / iOS 13 - Your manual `window`, `MyViewController()` and `makeKeyAndVisible()` logic has to go in `SceneDelegate`'s `func scene(_ scene: UIScene, willConnectTo ...` method. See Parth Tamane's answer for details. – Nikolay Suvandzhiev Nov 06 '19 at 17:16
112

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

Parth
  • 2,682
  • 1
  • 20
  • 39
  • 7
    _**Your answer is almost correct just there is a little change in scene function:**_ `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() }` – Reza Dehnavi Nov 02 '19 at 11:47
  • 3
    To add some emphasis, the info.plist entry is not just the usual main storyboard entry but ALSO the one in the application scene manifest which is new for iOS 13. I had to read through twice before I realized. – jboulter11 Dec 09 '19 at 23:46
  • This is the right way of doing things now! ^^ Apple kept changing things. – Yuchen May 28 '20 at 19:50
  • 1
    If you are a Xamarin dev, I found this to be very helpful: https://talkwithangel.com/creating-xamarin-ios-views-imperatively-without-storyboards-with-ios-13-breaking-changes/ – Chucky Feb 15 '21 at 16:00
63

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

JAL
  • 41,701
  • 23
  • 172
  • 300
Geekoder
  • 1,531
  • 10
  • 21
62

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.

Shubham
  • 808
  • 8
  • 14
  • 1
    This is absolutely the right answer. It's apparently no longer enough to set the main storyboard from the General > Main Interface dropdown. – NRitH Feb 18 '20 at 23:23
  • 1
    Thanks for this. Deleting the "Application Scene Manifest" key (along with all of its sub-keys) resolved the problem for me. – Greg Brown Mar 29 '20 at 13:42
  • 3
    Thanks this is worked for me. if view is setup programmatically, you can just set the value to "LaunchScreen". – Amir Ehsanijam Jun 23 '21 at 20:13
26

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

ricardopereira
  • 11,118
  • 5
  • 63
  • 81
15

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

jeremywhuff
  • 2,911
  • 3
  • 29
  • 33
13

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.

kraftydevil
  • 5,144
  • 6
  • 43
  • 65
10

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!

Randika Vishman
  • 7,983
  • 3
  • 57
  • 80
  • Please help this am also facing this issue after installing the os10.14.1 and xc0de 10.1..am trying to resolve from 3 days but still ..my project works good in xcode9.1.. – Aruna M Nov 20 '18 at 11:47
  • @ArunaM Did you try the above steps which I have given in the answer? What was the status after doing this? – Randika Vishman Nov 20 '18 at 14:19
  • 1
    This was the solution when I removed a ViewController from the project which caused same error! – Slarty Bartfast May 30 '20 at 17:34
10

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.

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

I hope this helps.

Dohyeon
  • 115
  • 1
  • 7
8

Follow the steps:

1) First Click your story board

2) Then Click File Inspector

3) Then select "Target Membership"

Screen Shot

Vicky
  • 1,095
  • 16
  • 15
7

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

7

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>
nomnom
  • 936
  • 10
  • 21
6

Also, try removing the Storyboard name

enter image description here

Neha Vipin
  • 688
  • 6
  • 17
6

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.

John_Gers
  • 61
  • 1
  • 2
4
  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!!!
user1195202
  • 1,423
  • 1
  • 16
  • 20
4

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

4

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

  • 1
    Just ran into this issue running Xcode 14.3. This solved my problem. I did do a cmd+shift+f and searched for "main", which also lead me to the exact line label with 4 in the screenshot of the post – ribeto May 16 '23 at 14:42
2

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.

LentoMan
  • 166
  • 1
  • 7
1

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

1

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

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()
1

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

zeeshan
  • 4,913
  • 1
  • 49
  • 58
0

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

Chris
  • 581
  • 3
  • 17
0

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 ;-)

0

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

Community
  • 1
  • 1
Aqib Mumtaz
  • 4,936
  • 1
  • 36
  • 33
0

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.

roschach
  • 8,390
  • 14
  • 74
  • 124
Craig D
  • 351
  • 2
  • 7
0

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

Sk Borhan Uddin
  • 813
  • 1
  • 9
  • 19
0

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)
JESTIN SAJI
  • 53
  • 1
  • 15
-1

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 !!!

iSpeedyG
  • 1
  • 3
-1

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.

-3

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

Kerak
  • 5
  • 1