281

I got an error on Xcode saying that there was no information about the view controller.

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

Why is this happening?

Screenshot 1

Jayprakash Dubey
  • 35,723
  • 18
  • 170
  • 177
Ege Kaan Gürkan
  • 2,923
  • 2
  • 13
  • 24
  • 2
    I think this has been asked before: http://stackoverflow.com/questions/17735182/could-not-find-any-information-for-class-named-viewcontroller – Tapani Apr 28 '15 at 17:18
  • Deleting the derived data will surely work for you! – Anurag Sharma Dec 13 '16 at 04:56
  • **Same Issue happened with me I tried to close and restart my Xcode again and again but nothing happens and then I just try to restart my computer and it's done sometime Xcode can't understand properly so make sure it's work for you.** – Super Developer Mar 26 '18 at 06:02
  • I simply quitted Xcode, then re-open it. the compiler will re-load all files and it can detect the file you are looking for – Tran To Apr 18 '16 at 04:24
  • Check you don't already have an unconnected outlet in your view controller file. I discovered that I did. After I deleted it I had no issues. – Kex May 25 '16 at 11:44
  • This is a BUG in XCode, and I don't know why they don't fix it. You have to close XCode and re open. When you do try again to put the outlets, but this time leave a bunch of ENTERS before making it. You don't have to delete anything or waste your time on other options... This will solve your problems. – mavesonzini Jul 22 '16 at 16:05
  • For me none of above solutions worked.I had to delete view controller, **which i copied and pasted again in my storyboard to reuse that**.Then I dragged a new view controller in storyboard and every thing got fine :). I hope it might help someone with same problem. – Arslan Saleem Jun 20 '16 at 06:22
  • I was having the same exact issue. Make sure cells have reuse identifier. Table Views using Dynamic Prototypes require cells to have reuse identifier. Hope this solves your problem like it did mine:) – CoderCody Sep 11 '16 at 21:21
  • Just restarted XCode and no longer getting the error.. For me it happened when I renamed the class – Vimal Saifudin Mar 22 '17 at 20:41
  • best way to resolve this try to create a new "tableviewcell" class of type UITableViewCell and assign class of tableview cell to this tableviewcell and then clean your project ,after doing this you will not going to get this error. – Amit Verma May 08 '17 at 09:54
  • no need to delete anything. Just add the outlet manually @IBoutlet weak var imageName: UIImageView! and connect it to image by dragging this outlet to image. so rest of the items can be connected simply – umair Jun 03 '17 at 07:27
  • What worked for me was to delete a reference to an outlet from storyboard to .swift file. Then clean and reattach the outlet and it worked... No idea why it worked. – BlueBoy Jul 03 '17 at 06:10
  • Here is how it works for me: Close the tab window with the storyboard, and reopen it with a new tab. – Stone Jan 04 '18 at 02:31

19 Answers19

776

Here are some things that can fix this (in increasing order of difficulty):

  • Clean the project (Product > Clean)
  • Manually paste in

    @IBOutlet weak var viewName: UIView!
    // or
    @IBAction func viewTapped(_ sender: Any) { }
    

    and control drag to it. (Change type as needed.) Also see this.

  • Completely close Xcode and restart your project.

  • Delete the Derived Data folder (Go to Xcode > Preferences > Locations and click the gray arrow by the Derived Data folder. Then delete your project folder.)
  • Click delete on the class, remove reference (not Move to Trash), and add it back again. (see this answer)
Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
  • dont forget to remove the class on the view controller so that this steps will work – reggie Feb 13 '17 at 14:45
  • 9
    None of these steps worked for me in Xcode 8.3.2. I had to "Show Identity Inspector" > cleared the "Class" field (highlight the custom class's name and delete) > re-enter the class name in the "Class" field. Xcode auto-completed the class name. I then hit enter. – PeqNP May 31 '17 at 21:26
  • Add the line `alias purgederiveddata='rm -rf ~/Library/Developer/Xcode/DerivedData/*'` to your ~/.bashrc to use the command `purgederiveddata` to clear with one command – eskimwier Aug 15 '17 at 18:14
  • I found another way to fix this issue, this happened to me when I changed some build settings to improve my build speed. https://stackoverflow.com/a/50555888/2952876 – Mathias Van Houtte May 28 '18 at 08:30
  • I would strongly encourage you all to try my solution below. Would be gutted to know that people are having to restart their computers for a bug that shows frequently. – Stephen Paul Mar 02 '19 at 09:46
  • this is because xcode is so stupid and I don't really know what the _genius_ at apple are doing in the stores, they *should* be working on xcode development!! LOL... To workaround this issue, put your XIB file in the RIGHT part of the screen and your class in the LEFT part, then do the control-drag. – carlos_ms Jul 30 '19 at 21:51
  • Deleting derived data worked for me (Go to Xcode > Preferences > Locations) – pallavi Mar 30 '20 at 06:39
  • This happened to me today. Deleting derived data, clean, and then restart xcode resolved the issue. XCode Version 11.5 (11E608c) – Umit Jul 09 '20 at 06:02
  • Thank you for the solution options. Xcode sometimes gives me a headache without any reason :( – sugarakis Jan 27 '21 at 03:50
137

Or if none of the above works, type out the name of the outlet into the file first @IBOutlet weak var headerHeightConstraint: NSLayoutConstraint! and then click and drag from the outlet in the nib to the variable you just programmatically created. It should work without any of the hassle of cleaning, building, and deleting anything.

Stephen Paul
  • 2,762
  • 2
  • 21
  • 25
  • 5
    often the faster solution instead of spending ages to clean, build, etc. thanks. – mohonish Jul 21 '16 at 12:42
  • 1
    Very nice and once you do this the Automatic starts showing up, thanks. – AmJa Oct 04 '16 at 21:21
  • 1
    Fist of all connect your XIB Object to IBoutlets.Then try to connect their constraints IBOutlets. without this it will always show error. – Chandramani Dec 02 '16 at 06:11
  • It can also make a difference where you try to insert the new outlet. For, the top of the list (where there is clear space above) worked; the middle of the list did not. – Richard Apr 02 '17 at 16:30
  • @Richard That is something I have noticed as well. Cheers for the input. BTW, I believe we have worked together! Small world. – Stephen Paul Apr 21 '17 at 23:56
  • 1
    This should be marked as the best answer. It is easier, faster and more reliable. Also it works all the time! Good job and thanks @StephenPaul – denis_lor Feb 11 '19 at 10:58
  • Someone elaborate us the answer visually! – Oskar Feb 13 '19 at 11:27
61

Just perform the two following steps to get rid of this error

  1. Clean project using Product > clean
  2. Run the project

Now try to add the action or outlet. That's it.

Happy Coding

Quango
  • 12,338
  • 6
  • 48
  • 83
Akshaykumar Maldhure
  • 1,239
  • 1
  • 18
  • 32
  • 5
    Strange ... this easy two steps helped to solve the problem for me, too. So I recommend, to try these easy steps first :-) – crosscode Jan 08 '17 at 06:53
50

None of the tips in the best answer worked for me. Was going crazy. Then noticed that the Assistant Editor had somehow gotten set to Manual and I was on the ViewController.swift (Interface) instead of the ViewController.swift file.

Changed that and problem solved. A bit embarrassing but hey, we are all learning.

enter image description here

Joshua Dance
  • 8,847
  • 4
  • 67
  • 72
  • 1
    Life saver answer! None of the other answers solved it once and forever. Too bad that the error description does not give the least hint that you might be in the worng file. Thanks. +1 for the image it made it all clear. – Pauloco Jun 14 '18 at 08:34
  • I noticed something pretty similar, but different : In the path at top where the name of class is displayed, there was just the class name, but missing beginning of path as myProject > appName > controller and then the class. I selected another class then back to the problematic one, and everything OK – claude31 Nov 09 '18 at 13:07
21

Here are the steps solved for me:

  1. Remove Class name reference from View(storyboard/xib) and save;
  2. Add Class name again and save;
  3. Clean and Build;

Done !

Almeida
  • 1,254
  • 12
  • 26
11

I had the same issue. I tired below solutions but didn’t worked :

  1. Clean Project (cmd + shift + k) and even Clean Project Build (cmd + shift + alt + k)
  2. Deleted Derived data and Module Cache content

Below workaround to this issue :

  1. Move to source code file and write the IBOutlet / IBAction manually (copy paste preferred)

Screenshot 1

  1. Then move to Storyboard file and Open Utilites window
  2. Goto Connection Inspector
  3. Then Connect the IBOutlet and IBAction written in source file with Interface Builder.

Screenshot 2

Jayprakash Dubey
  • 35,723
  • 18
  • 170
  • 177
  • Dragging Outlets/Actions weren't working at all, but after I did it manually like this, everything worked properly again. – Jason Mar 17 '17 at 00:11
  • This is a standard alternative method to make connections. In the case of radio button actions, the only way, AFAIK. In the storyboard, you can also right click on the controller, find the function, and make the connection. – curt Jul 06 '17 at 16:10
8

I had the same problem. I realised than in X-Code Manual item was selected when I tried to create an outlet by control-drag

enter image description here

After I set it to automatic it worked

enter image description here

Vitalii
  • 10,091
  • 18
  • 83
  • 151
7
  1. Close the project you are working on with.
  2. Delete your project's【DerivedData】folder. (This folder may inside your project's folder, or inside
    ~/Library/Developer/Xcode/DerivedData/
    (your project)/) or somewhere else that was setup by you.
  3. restart your project.
Sangram Shivankar
  • 3,535
  • 3
  • 26
  • 38
Ali
  • 514
  • 5
  • 16
7

I solved this problem by programmatically creating the Labels and Textfields, and then Command-Dragged from the little empty circles on the left of the code to the components on the Storyboard. To illustrate my point: I wrote @IBOutlet weak var HelloLabel: UILabel!, and then pressed Command and dragged the code into the component on the storyboard.

KuboAndTwoStrings
  • 864
  • 12
  • 20
  • This solution worked perfectly for me! Apart from the `@IBOutlet weak var myButton: UIButton` I used the same process to set up `@IBAction func doSomething(_ sender: Any) { }` and then connected this func to _UIButton_ on my storyboard. Thanks for sharing this @KuboAndTwoStrings – Nii Mantse Sep 06 '17 at 11:17
4

I got this bug when I renamed the class. Then I solved it just by following the below steps

  • In Xcode Menu -> Product -> Clean
  • Restart the Xcode
Vinoth Vino
  • 9,166
  • 3
  • 66
  • 70
4

I found an easier workaround as I this bug can be found on XCODE 9.

Step one go to your viewcontroller and manually write the property you want to connect as the below example, make sure you use the below format.

@IBOutlet weak var questionsStackView: UIStackView!

Step two go to your storyboard and connect your view or whatever your trying to connect to the property you created in step 1.

The above will save you time of removing and cleaning derived data.

GyroCocoa
  • 1,542
  • 16
  • 19
4

Please perform the following two steps only to get rid of this error.

1.  Clean Project using Product -> clean.
2.  Run the Project.

Now try to add/Connect the actions or outlets.

Working Fine for me for many times.

Devendra Singh
  • 717
  • 1
  • 13
  • 14
2

In my case this was bc I chose a new UIViewController file in IB and then tried to ctrl-drag to this new controller without first removing the previous connections in the Connections Inspector. Remove those first and try again.

Marius Waldal
  • 9,537
  • 4
  • 30
  • 44
2

For me it worked when on the right tab > Localization, I checked English check box. Initially only Base was checked. After that I had no more problems. Hope this helps!

lmicu
  • 21
  • 1
2

enter image description here

I selected Automatic option to select the ViewController.swift file. And then I can able to take outlets.

Arpit B Parekh
  • 1,932
  • 5
  • 36
  • 57
1

None of this worked for me but I did figure this out.

Inside the storyboard I copied the corresponding ViewController into the clipboard and deleted it, afterwards I pasted it again.

Suddenly everything was working like a charm again!

Markus
  • 686
  • 1
  • 11
  • 18
1

It happened when I added a Swift file into an Objective-C project .
So , in this situation what you can do is . .

  • Select MY_FILE.Swift >> Delete >> Remove Reference
  • Select MY_FOLDER >> Add MY_FILE.Swift
  • Voila ! You are good to go .
roy
  • 6,685
  • 3
  • 26
  • 39
  • Up for this! I've been trying to solve this issue on my own for half an hour already lol. Problems like this in Storyboards are easy to fix though. Thanks! This helped me a lot! – Glenn Posadas Jan 13 '20 at 14:52
0

Simplest solution:- I used xCode 7 and iOS 9.

in your .m

delete #import "VC.h"

save .m and link your outlet again it work fine.

Ahmed Abdallah
  • 2,338
  • 1
  • 19
  • 30
0

I used xCode 7 and iOS 9.

in your .m

delete #import "VC.h"

save .m and link your outlet again it work fine.

in your .m

add #import "VC.h"

save .m

Ahmed Abdallah
  • 2,338
  • 1
  • 19
  • 30