170

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?

ttarchala
  • 4,277
  • 2
  • 26
  • 36
user2597451
  • 1,903
  • 2
  • 12
  • 10
  • Are you triple sure that the ViewController .m file is included in the proper target? (checkbox in the righthand inspector panel) – Alfie Hanssen Jul 18 '13 at 22:42
  • 2
    You have a view controller in your storyboard and specified "ViewController" for the name of the class that should be instantiated to manage the view. Check each view controller in the storyboard: select the view controller, look at the "identity inspector" on the right-hand pane, and look at the "Custom Class" property. If it reads "ViewController" then there's your problem. Put in the name of the class that should manage your view controller... or put in UIViewController to get the default UIKit implementation. – Nicholas Hart Jul 18 '13 at 22:44
  • 1
    I changed the custom class to "UIViewController" in the identity inspector, and was no longer able to ctrl-drag from the storyboard into ViewController.h. If I create a new class and try to ctrl-drag into it (after setting the view controller's class accordingly), I get the same "Could not find any information" error. – user2597451 Jul 19 '13 at 01:09
  • 4
    I had this problem, and *modifying* the auto-generated ViewController class worked for me. E.g. just add an `NSLog()` to `viewDidLoad:` – j b Oct 08 '14 at 12:15
  • 1
    Possible duplicate of [Could not insert new outlet connection: Could not find any information for the class named](http://stackoverflow.com/questions/29923881/could-not-insert-new-outlet-connection-could-not-find-any-information-for-the-c) – Andrew_STOP_RU_WAR_IN_UA Sep 15 '16 at 21:53
  • In my case, I had created a View Controller named "aaa", removed the reference but did not delete. I meant to delete as well as remove reference. So I went to the file system and deleted the file there. Then I recreated a new View Controller with the same name. I did wonder if there would be a left over problem that was not obvious to me as I'm new to Swift. I ended up doing a Build->Clean and then restarted XCode ("open myproject.xcworkspace). Then I was able to drag the outlet without error. – Lucy Oct 21 '17 at 14:30

41 Answers41

320

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

Chris Harrison
  • 5,512
  • 3
  • 28
  • 36
  • I also tried what is listed in this answer as not working. I also renamed the VC to something else and tried again. Still no luck. – Michael Jan 16 '15 at 00:19
  • 2
    @Michael, Yes, now I'm in a situation where none of the above works at all. Xcode is a *** – Chris Harrison Feb 06 '15 at 09:43
  • also make sure your file is in the correct folder. i've placed mine in the same folder as the appdelegate.swift file – Jason G Aug 24 '15 at 14:46
  • Thank you, this worked for me too. Xcode v 7.0.1. I deleted the references to both the .h and the .m files, then added them again. – kshepherd Feb 16 '16 at 16:40
  • 5
    This issue dates back to Jul 2013, as of today May 2016 I get the same bug and fixed it with this answer. How come in so many years Apple doesn't fix it for good? – SkyWalker May 05 '16 at 15:20
  • 3
    2017 (Version 8.2 (8C38)) and still alive, Xcode SUCKS. It happens to me when you copy-paste UI staff from the storyboard from one scene to another – Jaime Agudo Jan 04 '17 at 11:20
  • worked for me! Things that did not work: 1. clean 2. blow away derived data 3. close and reopen 4. remove/readd class name in IB 5. typing @IBOutlet var ... and manually linking 6. creating a new file and copy and pasting the class 7. general raging at my laptop, xcode, apple, tim cook, etc – Josh Jan 12 '18 at 03:07
  • 1
    April 19th 2018, still have this stupid bug in Xcode 9.3. Unbelievable, I'm wondering how Apple uses my 99$ per year. – Massimo Polimeni Apr 19 '18 at 07:29
  • Xcode 10 beta 5, still an issue (I had to join in, this was too funny scrolling through and seeing every version of Xcode) – bearacuda13 Aug 08 '18 at 19:48
  • I deleted the class completely, added it back as a new file and then tried connecting. Worked for me. Then I just added the code back manually. This worked for me. I am on XCode 11. – BVB09 Dec 21 '19 at 09:56
  • This issue still persists in 2021, Xcode 13.1. You still have to delete the file(not the reference, the actual file) and create a new file with whatever name and hook it up with Storyboard.. – Junsu Kim Dec 06 '21 at 04:33
143

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.

Andrew Robinson
  • 3,404
  • 3
  • 20
  • 26
  • 6
    @Gmeister4, if you create an outlet in your code it shows a small circle to the left of the outlet. Click and drag from that circle to the view in IB or Storyboard to make your connection. – Andrew Robinson Oct 13 '15 at 20:37
  • Ah I see. Didnt realise you could do that. Thanks! – Gmeister4 Oct 13 '15 at 22:25
  • 2
    Still can't do it the proper way around, not even after this - but at least *this* works! – Alexandre G Dec 01 '15 at 05:04
  • After writing @IBOutlet in code I was able to drag to this outlet from Storyboard (not to small circle but to blue square that appears) – franiis Jul 12 '17 at 07:21
  • It's 2017, Xcode 9.0.1 and this answer was helpful. It also needed to be done once, all next outlets can be connected with mouse. What's worse, it is possible that all other answers are equally good, but we have to pick one working in particular configuration. – Tomek Cejner Oct 27 '17 at 11:01
  • It has to be one of the most annoying "little" bugs I've encountered. It's just habit now to perform the above whenever Xcode forgets how to behave. – Andrew Robinson Oct 31 '17 at 13:53
  • Tried to restart and didn't work, then added manually entered like above and didnt work. Restarted again and it worked!! – BrianMiz Jan 30 '18 at 22:56
  • 1
    still a bug in 2018, this fixed it. Filing a radar with Apple, this is ridiculous. – GoatInTheMachine Jun 02 '18 at 15:31
  • Sometimes it feels like Xcode do not know what to do :| but I am glad that you know what to do (Y) – Abuzar Amin Aug 02 '19 at 07:09
  • It's so annoying that Xcode constantly seems to be working against you. How can this "IDE" still be so horrible!? – Git.Coach Aug 27 '19 at 20:30
43

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

Ruud Visser
  • 3,381
  • 2
  • 20
  • 19
13

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

MRizwan33
  • 2,723
  • 6
  • 31
  • 42
8

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.

shim
  • 9,289
  • 12
  • 69
  • 108
gmogames
  • 2,993
  • 1
  • 28
  • 40
8

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

shim
  • 9,289
  • 12
  • 69
  • 108
Jesus Rodriguez
  • 2,571
  • 2
  • 22
  • 38
7

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

Amr Angry
  • 3,711
  • 1
  • 45
  • 37
4

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.
yndolok
  • 5,197
  • 2
  • 42
  • 46
4

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

Community
  • 1
  • 1
Joe149
  • 81
  • 3
3

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!

Elliot KG
  • 51
  • 4
3

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.

Renats Stozkovs
  • 2,549
  • 10
  • 22
  • 26
Hayden Crabb
  • 108
  • 6
3

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.

Damo
  • 12,840
  • 3
  • 51
  • 62
3

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)

programmer
  • 507
  • 5
  • 16
2

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

tungnv
  • 29
  • 3
2

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

JohnVanDijk
  • 3,546
  • 1
  • 24
  • 27
2

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

Jangles
  • 31
  • 2
2

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

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.

inix
  • 485
  • 1
  • 5
  • 12
1

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.

Jake
  • 113
  • 7
1

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!

shim
  • 9,289
  • 12
  • 69
  • 108
arqam
  • 3,582
  • 5
  • 34
  • 69
1

Just need to clean and re-build the project.

1

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!

MalaKa
  • 3,734
  • 2
  • 18
  • 31
John Nolan
  • 65
  • 9
1

I just restart Xcode and then it works.

shim
  • 9,289
  • 12
  • 69
  • 108
sixsixsix
  • 1,768
  • 21
  • 19
1

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

Will Buffington
  • 1,048
  • 11
  • 13
1

I tried EVERYTHING!

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

Bug Report submitted.

Aaron Kreipe
  • 309
  • 3
  • 8
0

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.

CaptJak
  • 3,592
  • 1
  • 29
  • 50
  • Still doesn't work, unfortunately. I've tried to do this before to no avail. Here's a screenshot: http://i.imgur.com/5ixtcps.png – user2597451 Jul 19 '13 at 18:46
  • Huh. Strange. Try adding them in programmatically (i.e. @property (nonatomic, strong) IBOutlet UIView *test;) and then when the little circle appears next to it, drag and drop to your UIView. – CaptJak Jul 19 '13 at 18:55
  • That works and always has (and the apps seem to run okay), but I'm trying to solve the problem that it won't add automatically. – user2597451 Jul 19 '13 at 19:18
  • Well, if it works like that, then it should work the other way. Bug in your XCode? Try to get a previous version (like 4.6.2 or something) and install that. Otherwise, ummmmmmmmmmmmmmm...... yeah.... – CaptJak Jul 19 '13 at 19:37
  • Yeah, that's what I'm afraid of. Uninstalling and reinstalling hasn't been working, I was hoping I was making a mistake. What's the best way to downgrade my copy of Xcode? – user2597451 Jul 19 '13 at 23:38
  • @user2597451 Sorry for the wait, but Apple seems to have a web page down for their xcode downloads. Normally, you would just go [to this page](https://developer.apple.com/xcode/) and click the "View Downloads". There you should see various versions of XCode, just download and install accordingly. – CaptJak Jul 20 '13 at 02:23
  • Just had the same happen for me in Xcode 5. Never seen this before. Tried dragging an IBOutlet into the viewController header and got that message. Restarting Xcode worked for me. Why, I have no idea. – Alex Zavatone Sep 18 '14 at 14:29
0

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

Community
  • 1
  • 1
Michael
  • 2,973
  • 1
  • 27
  • 67
  • Deleting derived data or cleaning rebuilding project or closing xcode did not work for me. I just created new viewcontroller class then copied- pasted old one but not class name included. so it started to work. – Burcu Kutluay Oct 12 '20 at 13:45
0

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

jomafer
  • 2,655
  • 1
  • 32
  • 47
0

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.
}
Lyndsey Scott
  • 37,080
  • 10
  • 92
  • 128
0

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.

0

Just try to delete Derived Data for the project

david.gol
  • 19
  • 1
  • 2
0

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 
Aditya Vyas-Lakhan
  • 13,409
  • 16
  • 61
  • 96
yousuke
  • 11
  • 1
0

Check from finder Xcode whether closed or not.

Force quit Xcode and restart.

Product > Clean

shim
  • 9,289
  • 12
  • 69
  • 108
erdikanik
  • 674
  • 9
  • 11
0

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

shim
  • 9,289
  • 12
  • 69
  • 108
David Wood
  • 29
  • 3
0

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)

Sandu
  • 436
  • 4
  • 8
0

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.

CristianMoisei
  • 2,071
  • 2
  • 22
  • 28
0

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.

andesta.erfan
  • 972
  • 2
  • 12
  • 30
0

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.

vikash singh
  • 1,479
  • 1
  • 19
  • 29
0

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

Melad
  • 1,184
  • 14
  • 18
0

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

Resly34
  • 7
  • 4
0

Xcode Storyboard error

Could not insert new outlet connection: Could not find any information for the class named <controller_name>

This error also is occurred when you rename Main.storyboard(e.g. to Foo.storyboard) and try to connect storyboard with controller

To fix it just set correct name in Info.plist UISceneStoryboardFile string (in out case - Foo)

yoAlex5
  • 29,217
  • 8
  • 193
  • 205