“Could not find any information for class named Vi

2019-01-12 22:57发布

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?

30条回答
Rolldiameter
2楼-- · 2019-01-12 23:28

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!

查看更多
三岁会撩人
3楼-- · 2019-01-12 23:30

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

查看更多
冷血范
4楼-- · 2019-01-12 23:31

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.

查看更多
迷人小祖宗
5楼-- · 2019-01-12 23:32

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.
}
查看更多
家丑人穷心不美
6楼-- · 2019-01-12 23:34

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!

查看更多
虎瘦雄心在
7楼-- · 2019-01-12 23:34

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.

查看更多
登录 后发表回答