[ios] Storyboard doesn't contain a view controller with identifier

I keep getting the following error:

Storyboard (<UIStoryboard: 0x7ebdd20>) doesn't contain a view controller with identifier 'drivingDetails'

This is the code:

- (void)tableView:(UITableView *)tableView 
        didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

   UIViewController *controller =  [self.storyboard instantiateViewControllerWithIdentifier:@"drivingDetails"];
   controller.title = [[dao libraryItemAtIndex:indexPath.row] valueForKey:@"name"];
   [self.navigationController pushViewController:controller animated:YES];
}

I have already set the identifier on the UIStoryboard but I'm still getting this error.

enter image description here


This question is related to ios objective-c xcode storyboard

The answer is


I found it ... click on the view controller in storyboard, click the third icon from left on the vc attributes inspectors - the one where you set the call name on that scereen it says 'identity' - mine was hidden , i had to click on the word identity it then shows storyboardID - add the identifier from the code, done


XCODE DRAG N DROP PANE IS GONE!!!

enter image description here enter image description here


it is very simple select the respective view controller in the main story board and check the storyboardID if its present use it in the identidier of give a name and use it.

here my firstone is the storyboardID let vc = self.storyboard?.instantiateViewController(withIdentifier: "firstone") as! tabBarViewController


Identity located in Identity Inspector tab named Storyboard ID for Xcode 6.3.2 and checked Use Storyboard ID option. enter image description here


let storyboard = UIStoryboard(name: "StoryboardFileName", bundle: nil)
let controller = storyboard.instantiateViewController(withIdentifier: "StoryboardID")
self.present(controller, animated: true, completion: nil)

Note:

  • "StoryboardFileName" is the filename of the Storyboard and not the ID of the storyboard!
  • "StoryboardID" is the ID you have manually set in the identity inspector for that storyboard (see screenshot below).

Storyboard ID

Sometimes people believe that the first one is the Storyboard ID and the second one the View Controller class name, so note the difference.


Just had this issue after adding a new VC to the storyboard but only on the device, not on the simulator. Turns out it was due to having multiple storyboard localizations - the VC was only added to the primary one. I tried removing the other localizations (one of which is the one my iPhone uses) but still had the error. In the end I had to recreate the other localizations with the new VC in each of them.


In Xcode 7 - 13,

when you change storyboard IDs and you get errors like this,

just CLEAN your project (CMD+SHIFT+K)


Cleaning all things and closing Xcode doesn't solved the issue for me.

I had to delete the viewController and create a new one with new identifier.


Compiler shows following error :

Terminating app due to uncaught exception 'NSInvalidArgumentException',
reason: 'Storyboard (<UIStoryboard: 0x7fedf2d5c9a0>) doesn't contain a 
ViewController with identifier 'SBAddEmployeeVC''

Here the object of the storyboard created is not the main storyboard which contains our ViewControllers. As storyboard file on which we work is named as Main.storyboard. So we need to have reference of object of the Main.storyboard.

Use following code for that :

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:[NSBundle mainBundle]];

Here storyboardWithName is the name of the storyboard file we are working with and bundle specifies the bundle in which our storyboard is (i.e. mainBundle).


Modifying "Storyboard ID" in the identity inspector (the 3rd icon to the left) should work.

If not and you're sure there's no typo, try cleaning up the project ("Product"->"Clean", or simply command + shift + K).


I tried all of the above solutions and none worked.

What I did was:

  • Project clean
  • Delete derived data
  • Restart Xcode
  • Re-enter the StoryboardID shown in previous answers (inside IB).

And then it worked. The shocking thing was that I had entered the Storyboar ID in interface builder and it got removed/deleted after opening Xcode again.

Hope this helps someone.


Use your identifier(@"drivingDetails") as Storyboard ID.


While entering the identifier u have not selected proper view controller, just check once if done repeat the procedure once more.


Note: If you use cocoapods in your project, then first run pod deintegrate and rm Podfile.lock

Then open your project folder in any third party code editor like VSCode and do a global search for the ViewController name throwing the error.

  1. Rename/fix any wrong names which you find.
  2. Save all changes.
  3. Clean and build your project.

Everything should work fine now.

This is most often caused when you rename files from within Xcode.


I got same error and I could fix this by changing the following changes in my project. I have mentioned my class name in the inspector panel then the problem is solved. Goto->right panel there Identity Inspector In the custom class section

class:your class name(ViewController)

In the Identity section storyboard ID:your storyboard ID(viewController Name)

After this click on Use storyboard ID option over there.That's it the problem is finished. I hope it will help you....


A few of my view controllers were missing the storyboardIdentifier attribute.

Before:

<viewController
    id="pka-il-u5E"
    customClass="YourViewControllerName"
    customModule="ModuleName"
    customModuleProvider="target"
    sceneMemberID="viewController">

After:

<viewController
    storyboardIdentifier="YourViewControllerName"   <----
    id="pka-il-u5E"
    customClass="YourViewControllerName"
    customModule="ModuleName"
    customModuleProvider="target"
    sceneMemberID="viewController">

Just for future reference:

I'm developing on iOS 6 using Storyboards.

I was having the same issue, but I could not find the "Identifier" field in the inspector. Instead, just set the field named "Storyboard ID" to what you would name the Identifier. This field can be found under the "Show the Identity inspector" tab in the inspector.

[Note - comments below indicate that some people have found that they need to (also?) set the field "Restoration ID" just below the Storyboard ID in the inspector. Clicking on "Use Storyboard ID" does not seem to be enough.]

There's an image below for reference: (in this instance I've named my identifier the same as my class) enter image description here


For those with the same issue as @Ravi Bhanushali, here is a Swift 4 solution:

let storyboard = UIStoryboard(name: "Main", bundle: Bundle.main)


Examples related to ios

Adding a UISegmentedControl to UITableView Crop image to specified size and picture location Undefined Symbols error when integrating Apptentive iOS SDK via Cocoapods Keep placeholder text in UITextField on input in IOS Accessing AppDelegate from framework? Autoresize View When SubViews are Added Warp \ bend effect on a UIView? Speech input for visually impaired users without the need to tap the screen make UITableViewCell selectable only while editing Xcode 12, building for iOS Simulator, but linking in object file built for iOS, for architecture arm64

Examples related to objective-c

Adding a UISegmentedControl to UITableView Keep placeholder text in UITextField on input in IOS Accessing AppDelegate from framework? Warp \ bend effect on a UIView? Use NSInteger as array index Detect if the device is iPhone X Linker Command failed with exit code 1 (use -v to see invocation), Xcode 8, Swift 3 ITSAppUsesNonExemptEncryption export compliance while internal testing? How to enable back/left swipe gesture in UINavigationController after setting leftBarButtonItem? Change status bar text color to light in iOS 9 with Objective-C

Examples related to xcode

Undefined Symbols error when integrating Apptentive iOS SDK via Cocoapods Xcode 12, building for iOS Simulator, but linking in object file built for iOS, for architecture arm64 iPhone is not available. Please reconnect the device Make a VStack fill the width of the screen in SwiftUI error Failed to build iOS project. We ran "xcodebuild" command but it exited with error code 65 The iOS Simulator deployment targets is set to 7.0, but the range of supported deployment target version for this platform is 8.0 to 12.1 Xcode 10.2.1 Command PhaseScriptExecution failed with a nonzero exit code Git is not working after macOS Update (xcrun: error: invalid active developer path (/Library/Developer/CommandLineTools) Xcode 10: A valid provisioning profile for this executable was not found Xcode 10, Command CodeSign failed with a nonzero exit code

Examples related to storyboard

How to make a simple rounded button in Storyboard? Outlets cannot be connected to repeating content iOS creating custom tableview cells in swift How to change Navigation Bar color in iOS 7? How can I switch views programmatically in a view controller? (Xcode, iPhone) How can I load storyboard programmatically from class? What is the difference between Modal and Push segue in Storyboards? Load view from an external xib file in storyboard Perform Segue programmatically and pass parameters to the destination view Custom Cell Row Height setting in storyboard is not responding