“Could not find any information for class named ViewController”

后端 未结 30 1817
南方客
南方客 2020-12-02 06:35

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

相关标签:
30条回答
  • 2020-12-02 07:21

    I just restart Xcode and then it works.

    0 讨论(0)
  • 2020-12-02 07:22

    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

    0 讨论(0)
  • 2020-12-02 07:23

    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

    0 讨论(0)
  • 2020-12-02 07:25

    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.
    0 讨论(0)
  • 2020-12-02 07:27

    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.

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

    0 讨论(0)
  • 2020-12-02 07:28

    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 and drag into the View which you want to connect (i have connected with TableView). and thats it. Enjoy Happy Coding!!!

    0 讨论(0)
提交回复
热议问题