I have started a new app a few days ago and began working with the simulator to test it. I started as an empty project and manually added the storyboard. The simulator build
If you are using for navigation on source code, try to use below code
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle: nil];
Often people will enter "Main.storyboard" for the name, since that is literally the name of the file, but for the purposes of Obj-C coding, "X.storyboard" has the name "X", so in this case, @"Main".
I had similar problem and I was getting the following error.
exception 'NSInvalidArgumentException', reason: 'Could not find a storyboard named 'MainStoryboard_iPhone' in bundle NSBundle
I fixed it by updating the plist file. Simply goto Edit->Find->Find in Workspace and search for "story". Now update the appropriate name for the story board.
There are 2 possibilities,
Select Storyboard > Go to file inspector (first right tab) > Check Target Membership
Initialize storyboard with proper bundle
.
bundle = nil
If storyboard is in different target than you are working on, then try following code to initialize bundle and storyboard.
let bundle = Bundle(for: MyClass.self)
let storyboard = UIStoryboard(name: "Main", bundle: bundle)
The problem occurs when you deselect "Use Base Internationalization" and run simulator in different locale rather than your specific localization.
For example, you specify a zh-CN localization in project setting but run simulator under en-US.
Nitin Alabur's answer helped me, but indirectly. Posting another answer to clarify:
I am building a dynamic framework with a storyboard inside it, and in the test app I am building to test the framework, I was getting this error.
My code looked like this:
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MyStoryboard" bundle:nil];
I was ignoring the NSBundle
stuff because, hey, I don't know what the heck a bundle is. Turns out it's important for this use case, where the storyboard will exist outside of the application's "bundle" (it's in my framework's bundle instead). This code will tell iOS to find the storyboard within the bundle that the current class exists in (which for me, is the bundle that contains my framework):
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"MyStoryboard" bundle:[NSBundle bundleForClass:[self class]]];
If you recently reset your iOS sim to default settings, it's also useful to check locale settings in its Preferences. I'm working on the app with Russian as the only locale and after sim reset the xCode stopped to start the app because the sim locale was set to English.