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
I just restart Xcode and then it works.
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
For me, the following worked:
Do a 'clean' and a 'clean build folder' (press 'option' on the Product menu to get the 'clean build folder' command
Stop Xcode
In terminal, go to the derived data folder:
(/Users//Library/Developer/Xcode/DerivedData)
Delete the derived data dir for your project.
Wave dead chicken in the air
Start Xcode
I had to do a combination of a couple of the answers so far:
(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)
(Right-click the file -> delete -> remove reference)
(Right click the folder where the file was -> "Add file to [project]")
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.
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!!!