18

After upgrading to Xcode 6, I opened an old project (that contains a subproject, so it has many targets) and I noticed that no link from my Storyboard ViewContoller to the relative Objects works.

For example I have a ViewController with a TableView inside and now I cant do can't do anyhing with it because the connection is missing, I can't even redefine a new IBOutlet in the VC because the arrow in the storyboard from the VC won't connect to anything.

To be more clear:

screenshot

The class is defined in the Custom Class section, so I can't find the problem

screenshot

What should I do? Btw I'm using obj-c not swift, I found some related answer but all about swift.

Cœur
  • 37,241
  • 25
  • 195
  • 267
lorenzop
  • 580
  • 1
  • 6
  • 24
  • make sure your module is selected in the module field in your photo. – Steve Rosenberg Oct 05 '14 at 15:50
  • EDIT: connecting a new IBOutlet with an arrow from the Storyboard to the Class Code insert it, but the connection doesn't work and shows the yellow warning like the two before. – lorenzop Oct 05 '14 at 15:50
  • Hi Steve, I also believe that this problem is related to the Module, but none is available under that section. How I solve that? – lorenzop Oct 05 '14 at 15:58
  • Uh oh! Let me look into this on one of my projects! – Steve Rosenberg Oct 05 '14 at 15:58
  • According to http://stackoverflow.com/questions/25931865/error-in-xcode-6-view-controller-does-not-have-an-outlet-named-subview it's an XCode 6 bug, downloading 6.1, will try it and come back here. – lorenzop Oct 05 '14 at 16:24

16 Answers16

52

You can also see that the link between the parent view and the custom class is broken (not visible anymore) which is a huge problem.

I had the exact same issue with the app i'm working on actually, updating XCode from 5.xxx to 6.1. The workaround that worked for me was to remove the reference of every view controller and re-add them to the project...

To everyone facing that issue, here's the (annoying) trick :

  • Step 1 : select both .h and .m view controller files
  • Step 2 : remove the reference of those files
  • Step 3 : re-add the files to your project tree
  • Step 4 : open the storyboard, eventually re-build the project and smile

I can understand those things could be reaaally annoying, but it worked for me... Hope it will help someone else !

Jerome
  • 915
  • 8
  • 17
  • I had already upgraded to XCode 6.1, then added a view controller, maybe I did something wrong but the IBOutlets would not connect. Something was fishy as the syntax highlighting crashed as well. Removing the reference and re-adding worked like a charm! – vikke Jan 07 '15 at 18:04
  • You just saved my computer from being broken – Itai Spector Sep 16 '15 at 14:18
  • 1
    This is an awesome answer. Helped me to get rid of my big struggle. Thanks. – Neela Oct 19 '17 at 20:41
22

In your storyboard hierarchy select the View Controller,

enter image description here

In the right pane Custom Class section Class, select the drop down and your desired view controller.

enter image description here

Tom Howard
  • 4,672
  • 2
  • 43
  • 48
  • Thanks so much! I renamed my `ViewController`s when I added a new one, and it messed up my drag and drop connections. And sure enough, when I checked the `Class` it was assigned to, it said the old `ViewController` name. Selecting the right name from the drop down fixed it. – Azurespot Jun 30 '16 at 00:48
5

I've experienced similar behaviour in Xcode 6.1.1 when trying to add the first outlet to a new view.

Tried removing the references and adding the files again as suggested above with no success.

What I did find worked was writing the first property on the new view by hand. I just popped in:

@property NSString *temp;

I could then attach my outlets in the normal way. Just delete the temporary property once you've added your first outlet.

Hope this helps.

Adam Nierzad
  • 942
  • 6
  • 19
  • Just encountered this in Xcode 7.2. Totally frustrating and can't believe this is an issue still - thanks for posting this! – Derek Lee Jan 18 '16 at 23:27
4

It seems typing the outlet first (swift):

@IBOutlet weak var someViewOutlet: UIView!

and then dragging from IB the outlet to the far right type in the above code works.

Restarting Xcode resolves the issue (sometimes). Using Xcode 6.1

hugey
  • 51
  • 3
  • It works! (Praise the Lord) : I just wanted to add a few comments: If you want to get the right variable type NSConstraint, for example, attempt to Ctrl+drag from the UI element to the code and see the type, but click CANCEL or Xcode will crash. Now that you know the exact variable type, do as Hugey says, write the line of code manually. Finally do a Ctrl+Drag FROM the little circle to the left of the line of code, and drop the line over the View element. – Josh Jun 04 '15 at 10:57
4

Maybe I can help In my case the problem was that the viewController.swift file was not connected to the StoryBoard. The solution is to click in the Upper border of the view on the storyboard beside the 3 icons (View Controller, First Responder and Exit)...now look over in the Utility Area choose Identity Inspector, and in "Custom Class" choose the custom view controller.

Hope this helps. Xcode is hard!!

user462990
  • 5,472
  • 3
  • 33
  • 35
2

Here's the proper solution i believe.

If you renamed the controller in code, you need to update the .xib file.

I could not find a way to do it in the interface builder, so do this:

  1. Open the .xib file with a text editor: right click the file > open as > source code

  2. In the <objects> node find the <placeholder> node with the property placeholderIdentifier="IBFilesOwner" and replace the value in customClass="MyOldControllerName" with your new controller name: customClass="MyNewControllerName"

And all your IBOutlets will work as normal again.

  • This worked for me when the other approaches here failed. In my case, there was no customClass attribute, but I added one and everything began working when I switched back to IB. – Chuck Krutsinger Mar 02 '17 at 22:31
1

Thanks to everyone who commented.

It is a bug of Xcode 6 / 6.0.1. Downloaded and installed the 6.1 version and the problem disappeared.

lorenzop
  • 580
  • 1
  • 6
  • 24
0

Maybe try to delete the outlet from the menu in the storyboard (in your screenshot) and drag it again of the element.

Antoine
  • 1,139
  • 9
  • 21
  • Doesn't work, the arrow from the VC doesn't connect to anything, old or new outlets. In fact if I delete that Outlet I don't see it anymore. – lorenzop Oct 05 '14 at 15:31
0

Okay, let's check iff it is the lack of a module name.

  1. In your storyboard ViewController, type in the name of module. (the project name)

2.Clcick outside in another field. When you go back to the module field it may say none, but now there will be a dropdown menu entry for your project name.

  1. Select your project name and see if everything is good.

If there are still issues I will post photos.

Steve Rosenberg
  • 19,348
  • 7
  • 46
  • 53
0

Seems to be a workspace issue. Try to remove project form a workspace and add it again. It helped in my case.

P_O
  • 435
  • 6
  • 16
0

I had this, affected all projects on my machine, swift and objective c and drove me mad for ages. Finally also noticed that I could not use the refractor to rename classes either.

The fix for me was:

  1. Close xcode
  2. Delete ~/Library/Developer/Xcode/DerivedData (just doing this on its own did not work!!)
  3. Delete all user data for all my projects using the following from the directory that contains all my projects e.g. /src (be careful with this command!):

find . -name 'xcuserdata' -exec rm -rf {} \;

If you want to do it by hand just do the following for all your projects Delete .xcodeproj/project.xcworkspace/xcuserdata Delete .xcodeproj/xcuserdata/.xcuserdatad

  1. Get Spotlight to re-index the drive all my projects were on (not sure if this was required
  2. Re-boot machine

Everything sprang back into life !

Tim Teece
  • 21
  • 2
0

I was having this same issue.

It turns out I renamed my view controller class and file name. In storyboard, I had the stale value in the right pane, Custom Class -> Class. So the IBOutlets were not aligning because there were none in the missing class, which is where it was expecting to find the defined outlets.

Filling in the correct class name of the View Controller in the Custom Class field in the right pane fixed my issue.

XCode needs to be more verbose if you have a bad class name in the Custom Class fields.

Tyler
  • 19,113
  • 19
  • 94
  • 151
0

no one solution fixed my same problem... But i have solved by:

  • close xcode
  • renaming the folder of the project
  • open xcode

and then the outlets will be back again

I hope that this solution is the right one for the people who have the same problem

Kazzar
  • 1,432
  • 1
  • 11
  • 9
0

In Xcode 6.3 I needed to close Xcode and restart the Mac. Restarting Xcode alone didn't do it for me.

I've had 6.3 for a long time and my problem was with new projects I was creating to test some things. Definitely not an upgrade issue this time.

Dan Loughney
  • 4,647
  • 3
  • 25
  • 40
0

I have Xcode 6.3 and saw similar issue. Finally few edits in .h file resolved my issue. If your interface has IBOutlet defined as

@interface NavigationViewController :UIViewController
{
  IBOutlet UILabel *lblName;
}

change this to and in .m file add @synthesize lblName;

@interface NavigationViewController :UIViewController
{
   __weak  UILabel *lblName;
}

@property (nonatomic, weak) IBOutlet UILabel *lblName;
Ram G.
  • 3,045
  • 2
  • 25
  • 31
0

I was having this same problem, with no view outlet available to link to. The only way I was able to fix it was to change the owner class of the XIB file to "UIViewController," make the link, and then change it back to my intended custom view controller class. The link stayed and all was well.