"Could not find any information for class named ViewController"

IosXcodeIboutlet

Ios Problem Overview


This bug has been driving me nuts since I started using Xcode (4.6.3). Whenever I try to link a Storyboard item to my code, I get the error: >Could not find any information for class named ViewController.

This happens with custom classes as well. I've tried methods such as:

  • Deleting the delegate data.
  • Removing and re-adding the classes.
  • Restarting Xcode.
  • Reinstalling Xcode.

I can't ctrl-drag to create connections in any of my projects no matter what the class is. The same problem happens with a brand-new template application. If I type in the code manually and then ctrl-drag, I can make a working connection, but I can't add it automatically. Nothing I've been able to find so far on the Internet has helped. Any pointers?

Ios Solutions


Solution 1 - Ios

What solved this issue for me was actually deleting the class from the project.

Steps:

  1. In the project file explorer (left panel) find the class and right click -> Delete
  2. Remove reference (do not move to trash as you will lose the class for good)
  3. Right click on the folder that contained the class -> Add files to ...
  4. Find the class you just deleted in the file system

This seems to force Xcode to link the class back into the storyboard.

Note: for me the following did not work:

  • Closing Xcode
  • Cleaning the project
  • Deleting the class name from the storyboard and re-entering it

I think this is a bug on Apple's part

Solution 2 - Ios

In case anyone is still frustrated by this, there's a trick to get things working.

What I do is manually enter an outlet into my class, for example: @IBOutlet weak var someView: UIView!, and drag from the code to the view in IB or storyboard. After this, I am able to drag from IB / Storyboard to my class to make connections, assistant editors recognizes the class in "Automatic", etc...

Works every time.

Solution 3 - Ios

For me removing them from your target membership in the right column and adding them again did the trick enter image description here

Solution 4 - Ios

Sometime Xcode does due to VC not referencing class file. The simple solution for this is:

write property manually as given.

class YourClassName{

     @IBOutlet weak var YourTableName: UITableView!

}

This will make a empty link sign before @IBOutlet, open your project in assistant editor then click link sign enter image description here and drag into the View which you want to connect (i have connected with TableView). and thats it. Enjoy Happy Coding!!!

Solution 5 - Ios

I tried everything and it didn't work, so for me what worked is:

  • Clean Build folder and project.
  • Open Projects (Window -> Projects)
  • Find your project on the list and delete the Derived Data
  • Close Xcode
  • Restart computer (without choosing to reopen windows that are open)
  • run Xcode
  • Work!

All my view controllers were not being recognized, so deleting all files and re-adding was not an option as this is a big project.

Solution 6 - Ios

I just had this problem on April 2017 with Xcode 8

Simply creating an outlet through code and compiling fixed it. eg:

@IBOutlet weak var containerViewHeight: NSLayoutConstraint!

You got to love Xcode…

Edit: Still happening on Xcode 9

Solution 7 - Ios

the following steps works for me hope that works for you also

1- You need to reopen you project after closing Xcode.

2- Wait for indexing project files

3- Check if it work or not

4- If still not working follow step 5, if not happy for you :)

5- Clean and Build your project target

enter image description here

Solution 8 - Ios

For me, the following worked:

  1. Do a 'clean' and a 'clean build folder' (press 'option' on the Product menu to get the 'clean build folder' command

  2. Stop Xcode

  3. In terminal, go to the derived data folder:

    (/Users//Library/Developer/Xcode/DerivedData)

Delete the derived data dir for your project.

  1. Wave dead chicken in the air

  2. Start Xcode

Solution 9 - Ios

I had to do a combination of a couple of the answers so far:

  1. Remove the custom class name from the storyboard.

(Click the yellow button at the top left of the view controller in the storyboard -> go to the identity inspector (option + command + 3) -> delete the custom class name at the top)

  1. Remove the reference to the view controller file.

(Right-click the file -> delete -> remove reference)

  1. Add the view controller file back to the project.

(Right click the folder where the file was -> "Add file to [project]")

  1. Add the custom class name back to the storyboard.

Solution 10 - Ios

If people try the above and things are still not working, the strange trick that worked for me was adding the outlet in a chunk of whitespace. It works if there are no other lines directly above or below the line you're adding. Strange, but it worked!

Solution 11 - Ios

What worked for me was, instead of dragging the connection from the button to the code, was:

  1. Clicking the desired storyboard item.
  2. Opening the connection inspector (right panel)
  3. Dragging from the + circle to the area of code. Like so:

after I linked my code in this way, it worked normally from thereafter.

Solution 12 - Ios

Stay On Target!

I was adding a new class with a Xib and I started seeing this issue and I spent a goodly time looking through the answers on here and seeing if any of it made a difference to it.

As it happens, I have multiple targets in my workspace and often I have to switch between them.

Turns out adding new files will kick start a re-index in Xcode. But if you are pointing at the wrong target then the indexing is likely to meaningless and during the drag to connect Xcode will not be able to find your class.

In short

Step 1.

Target Seledction

Make sure you have the correct target set so that indexing makes sense.

Solution 13 - Ios

This worked for me:

  1. Perform 'Clean build folder'
    (press and hold the 'option' key and go to the "Product" menu to access it.
  2. Perform a simple "Clean" (CMD-SHIFT-K) from the "Product" menu.
  3. Build the project to let Xcode compile the files. Also, let it index files if necessary.

On a side note, I am not sure if this helped but I also deleted the Derived data before performing the above steps (Xcode preferences > Locations)

Solution 14 - Ios

Select the ViewController in storyBoard, delete current value in Right hand panel/"Customer class"/"class" then re-add control class (type: "SampleViewController"...), enter. --> That work for me

Solution 15 - Ios

I tried all of these answers, the problem for me was related to Xcode not being able to index the files. I fixed this by simply quitting Xcode and reopening the project. Of course I did that after trying all of the above solutions :p

Solution 16 - Ios

Product > Clean (Command - Shift - K) fixed it for me!

Solution 17 - Ios

This is the EASIEST step that I did to fix this problem.

  1. I clean the project
  2. Drag a new button in the view controller.
  3. Build the project.
  4. Connect the newly dragged the button to the class (either outlet or action).
  5. Then voila!!! Other outlets can now be connected to the class again!

Solution 18 - Ios

As my testing experience,if you delete a class which was associated in the Xcode,and than add file again,than this issue will occur.

Solution 19 - Ios

Usually when this happens to me I just haven't saved the code for the class yet. Just hop over to the code and hit cmd+s and it often fixes the problem right way.

Solution 20 - Ios

Okay guys saw almost all top answers and none worked for me.

So what worked for me is the following:

  1. Copy the Derived Data address from your Xcode project. This can be done using the following:

Xcode -> Preferences -> Location Tab -> Derived Data

  1. Close Xcode

  2. Now go to the derived data location and delete the folder of your project there.

Now open Xcode and voila!

Solution 21 - Ios

Just need to clean and re-build the project.

Solution 22 - Ios

None of the steps above worked for me, but I think I may have discovered the issue. At least it is what worked for me, and it is not a bug in Xcode.

When in the assistant editor look at the top of the window that has the code for your viewController. The third option from the right likely says "Manual", but it should say "Automatic". Once I changed this, the problem was resolved!

Solution 23 - Ios

I just restart Xcode and then it works.

Solution 24 - Ios

I was getting a similar problem, "Could not find a class named..." and the cause was stupid on my part once I figured it out. Make sure you aren't dragging from the item to the interface - make sure it's being dragged to the class itself

Solution 25 - Ios

I tried EVERYTHING!

Make sure the class name of your UIViewController does not contain the word "Test"

Bug Report submitted.

Solution 26 - Ios

I would try to remake the .m and .h files in question and give them an original name, not generic like "ViewController". Try something more along the lines of what you want that file to do, and ending in View Controller (i.e. "PizzaDecoraterViewController")

Then select the ViewController that you want to connect to those files. Make sure that you select the ViewController, not just an object within. Click the black bar at the bottom (the one that has the "First Responder" and "Exit" icons). The entire ViewController should outline blue. Then go to the Custom Class section in the Identity Inspector and you should see a grayed out "UIViewController" in the first field. In that field, type in the name of the .h or .m file that you want it to connect to (Start typing PizzaDecorator... and it should do a little auto-complete thing). Then hit ENTER.

When you open up the Assistant Editor, make sure that the file that you are trying to drag and drop to is, in fact, the correct file.

If you have done all as said above, then it should work.

Solution 27 - Ios

As I commented on @ChrisHarrison's answer, those things did not work for me, but deleting the derived data as in I got it to work by deleting the derived data as in https://stackoverflow.com/a/16182672/1449799

Solution 28 - Ios

Delete the files (only the references) and add the files again.

Solution 29 - Ios

Well in my case, the thing that worked (it's a litle weird, but worked) is the following:

Try to add a datasource (ex. an extension to the ViewController like a UITableViewDataSource). Xcode will try to reload the ViewController. Then I wrote some method of the protocol (in the beginning Xcode did not autocomplete the methods, but wrote it out manually), then I added the IBOutlets, and then lastly, I removed the datasource.

Example:

class TestViewController:UIViewController{
    // This viewController presents “Could not find any information for  class named ViewController”
}

extension TestViewController:UITableViewDataSource{
    //Add Some methods of the protocol, Xcode will try to autocomplete and then it's going to reload the class, from then you can add your IBOulets / Actions .. And remove this extension if you don't need it otherwise.
}

Solution 30 - Ios

For me, the view I had specified a custom class for was failing to be compiled by interface builder. It was marked @IBDesignable.

Removing @IBDesignable, and then adding my outlets, and then marking it as @IBDesignable resolved the issue in my case.

Solution 31 - Ios

Just try to delete Derived Data for the project

Solution 32 - Ios

just try this

rm -rf ~/Library/Caches/com.apple.dt.Xcode
defaults delete com.apple.dt.Xcode IDEIndexDisable
defaults write com.apple.dt.Xcode IDEIndexEnable 1 

Solution 33 - Ios

Check from finder Xcode whether closed or not.

Force quit Xcode and restart.

Product > Clean

Solution 34 - Ios

In my case, it was because the Xcode indexing process had stopped running. Rebooting my Mac fixed it.

Solution 35 - Ios

Go to the project folder and delete derived data folder

if you cant find the derived data, go to finder and go to

 ~/Library/Developer/XCode/DerivedData/"project"

(replace "project" name with project name)

Solution 36 - Ios

I know this is in most cases just Xcode acting out, but in my case none of the suggested actions managed to fix the issue and I believe it was a mistake I made when trying to rename my project, so I ended up creating a new project and importing everything over.

This eventually fixed it.

Solution 37 - Ios

In my case I had a same class name and xcode could not recognize which one I am targeting so be careful in selecting name of your classes.

Solution 38 - Ios

What I did was to connect a button as an action with no arguments and sender as UIButton. The result was-

@IBAction func comma1() {
    
}

and I could put the rest of the outlets or actions.

Solution 39 - Ios

For me the issue was that there is a syntax error on the project. Everything worked fine after solving the error. I am working with xCode 11

Solution 40 - Ios

I got this problem after I applied the MVC architecture, after I changed the location of the info.plist file.

After specifying the new file location, the problem was resolved

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionuser2597451View Question on Stackoverflow
Solution 1 - IosChris HarrisonView Answer on Stackoverflow
Solution 2 - IosAndrew RobinsonView Answer on Stackoverflow
Solution 3 - IosRuud VisserView Answer on Stackoverflow
Solution 4 - IosMRizwan33View Answer on Stackoverflow
Solution 5 - IosgmogamesView Answer on Stackoverflow
Solution 6 - IosJesus RodriguezView Answer on Stackoverflow
Solution 7 - IosAmr AngryView Answer on Stackoverflow
Solution 8 - IosJoe149View Answer on Stackoverflow
Solution 9 - IosyndolokView Answer on Stackoverflow
Solution 10 - IosElliot KGView Answer on Stackoverflow
Solution 11 - IosHayden CrabbView Answer on Stackoverflow
Solution 12 - IosDamoView Answer on Stackoverflow
Solution 13 - IosprogrammerView Answer on Stackoverflow
Solution 14 - IostungnvView Answer on Stackoverflow
Solution 15 - IosJohnVanDijkView Answer on Stackoverflow
Solution 16 - IosJanglesView Answer on Stackoverflow
Solution 17 - Iosuser2480567View Answer on Stackoverflow
Solution 18 - IosinixView Answer on Stackoverflow
Solution 19 - IosDelimiterView Answer on Stackoverflow
Solution 20 - IosarqamView Answer on Stackoverflow
Solution 21 - IosCarolina AguilarView Answer on Stackoverflow
Solution 22 - IosJohn NolanView Answer on Stackoverflow
Solution 23 - Ios未来陆家嘴顶尖的投资人View Answer on Stackoverflow
Solution 24 - IosWill BuffingtonView Answer on Stackoverflow
Solution 25 - IosAaron KreipeView Answer on Stackoverflow
Solution 26 - IosCaptJakView Answer on Stackoverflow
Solution 27 - IosMichaelView Answer on Stackoverflow
Solution 28 - IosjomaferView Answer on Stackoverflow
Solution 29 - IosJosé Roberto AbreuView Answer on Stackoverflow
Solution 30 - IosNick DiZazzoView Answer on Stackoverflow
Solution 31 - Iosdavid.golView Answer on Stackoverflow
Solution 32 - IosyousukeView Answer on Stackoverflow
Solution 33 - IoserdikanikView Answer on Stackoverflow
Solution 34 - IosDavid WoodView Answer on Stackoverflow
Solution 35 - IosSanduView Answer on Stackoverflow
Solution 36 - IosCristianMoiseiView Answer on Stackoverflow
Solution 37 - Iosandesta.erfanView Answer on Stackoverflow
Solution 38 - IosCheong EayanView Answer on Stackoverflow
Solution 39 - IosMeladView Answer on Stackoverflow
Solution 40 - IosResly34View Answer on Stackoverflow