19

I can not drag anything to the code from the storyboard. Files were in assistant editor under automatic but now there gone how do i get them back other then deleting and recreating them? Opening them up under manual it will come up but Xcode can't find the referance when dragging to the code and i get the error when naming it.

dscrown
  • 578
  • 1
  • 5
  • 21

6 Answers6

20

I don't know if anyone else is still having this issue, but I get it a few times a week on Xcode 6.1.1 and I usually do the following to fix it (once I have checked that there are no class name mismatches):

  • Clean build
  • Delete Derived Data (using Organiser)
  • Force Quit Xcode
  • Re-open and Build

I know this is crazy, but it continues to work for me o_O

mdstroebel
  • 311
  • 3
  • 7
  • 1
    I was forced to do this after renaming a CustomViewController.m to CustomViewController.mm, only this worked. :) – Corwin Newall Jun 23 '15 at 00:58
  • Yuppi it's worked :D seems like derived data mess up. – mert Dec 11 '15 at 14:59
  • I tried a bunch of these recommended fixes but this one was the one that worked. **if you turned off indexing**, turn it back on **before** attempting this fix. Your associated files will only show up after Xcode is done indexing. – Trig3rz May 30 '16 at 15:16
  • I did everything here on my own except force quit Xcode. That got me over the finish line. Thank you! – Adrian May 18 '17 at 01:56
  • 3
    I encountered the same issue again today. These steps did not work until I clicked "Top Level Objects" instead of "Automatic". When I did that, something indexed at the top and then I clicked "Automatic" and bam...there was my viewController :) – Adrian May 29 '17 at 22:29
14

The most common cause is a mismatch between your class name and the name registered in the identity tab of the view controller. This will happen if you for example rename your class but don't update the classname in the storyboard.

To set/check the class name, open the storyboard and click on the leftmost icon in the titlebar of your UIViewController. Then open the identity inspector in the utility pane (right side) and double check the name given as the custom class.

oflibaer
  • 156
  • 2
  • 4
  • This worked for me. I added the Custom Class name for the storyboard. But my class doesn't show up in the automatic results in the assistant editor. However now I am able to create the outlet for the label. – Ronald Randon Nov 01 '15 at 17:12
  • I have a whole bunch of xibs where it doesn't automatically load the associated file. Some it does. I have all the `Class` properties set as you suggested. – toast Nov 19 '16 at 10:12
  • Everything looks same, but there is space in name given, So copy pasting same class name in left most icon in the title bar of viewcontroller works.. – Dharmik Mar 27 '20 at 14:33
2

The issue is due to not completion of indexing - so there are few alternatives, that you can try for-

Way 01 : Check if indexing is showing in processes - then let it complete. Then, close the editor and reopen it

Way 02 : Just perform the clean action. It will start showing appropriate Viewcontrollers.

Way 03 : This is the most effective way - Just perform "Build" and then restart editor - it will surely going to work.

Mehul Thakkar
  • 12,440
  • 10
  • 52
  • 81
  • I can tell that this did not work for me. The "Automatic" option is disabled and if I use "Manual", then Xcode complains. I have a regular Storyboard based project in Xcode 10 and Swift 4.2. Sometimes it works, sometimes it doesn't. Right now I can't figure out how to make it work again. – Alex Nov 09 '18 at 17:47
2

I had the same problem, and I managed to solve it by selecting the correct Target on the File Inspector of both files (Swift and XIB in my case, you can check the file inspector in the storyboard).

It can happen if your project has a lot of targets (mine had a few, the file was checked on the wrong one).

Mavi
  • 77
  • 1
  • 9
0

You'll want to turn XCode indexing 'on' and set the Assistant editor to “Automatic”. This helped in my situation when the other suggested answers didn't. Details on turning on indexing at Stopping xcode from indexing

Community
  • 1
  • 1
user4806509
  • 2,925
  • 5
  • 37
  • 72
0

I just deleted build folder completely.And it works for me!

ali shekari
  • 740
  • 1
  • 11
  • 26