Xcode 6 – ‘Ctrl Drag fails to create Outlet for UI component’ Fix

This seems to be a bug in the later versions of Xcode – specifically 4.0 and later, though it seems to work  in some cases without any problems. When you select a UI control in the storyboard, open the AssistantEditor and control-drag it to the relevant file in the editor, nothing happens.

Screen Shot 2015-09-25 at 6.24.58 PM

 

 

 

 

 

 

 

 

 

A lot of people face this problem and the general solutions provided are:

  • The wrong file is open in the Assistant Editor
  • The correct class file needs to be assigned to the the Storyboard, specially if you are using a custom Viewcontroller class.
  • Deleting the working files of the project and loading it again in Xcode.

I was not able to resolve my problem with the above solutions. But the reason for the problem was clear – the correct class was not assigned to the Storyboard so it was rejecting the creation of an Outlet. I found that out of 5 scenes in the storyboard, only the last 2 were having this problem and the other 3 did not have this problem. On investigating this further, I found that the the storyboard had not assigned the customClass and customModule attributes  to the viewController xml tag to the two scenes where this problem existed, whereas the other 3 scenes where Outlets could be created, these attributes were there.

Screen Shot 2015-09-25 at 6.46.18 PM

 

 

\

 

 

 

 

 

After manually adding the attributes directly in the Storyboard file xml, the problem went away and the Outlets could be created.

<viewController id="BYZ-38-t0r" customClass="ViewController" customModule="Swerk" customModuleProvider="target" sceneMemberID="viewController">

 

 

 

Be the first to comment

Leave a Reply

Your email address will not be published.


*