18

I just got this error in one of my apps, and after checking some other apps the same error is happening. None of my IBOutlets and IBActions are connected anymore. When I recreate the outlet by control-dragging into the .h file, the outlet still displays the error in Connections Inspector > Outlets, saying (view controller) does not have an outlet named (subview). Before today I didn't have this problem, so is to do with Xcode 6? The view controller is referencing the correct class under Identity Inspector > Custom Class. I have deleted the derived data folder, removed the reference to the .h file, cleaned the project, and cleaned the build folder. None of that has worked and I can't progress with development until this issue is fixed.

Outlets show exclamation mark. Note 'easyLabel'

I disconnect easyLabel, and the outlet disappears. I can't reconnect it with drag and drop.

Update: I just reopened the project after a couple of days and my outlets no longer have the exclamation mark next to them, and the 'easyLabel' outlet that I disconnected has reappeared. I didn't change anything, so I guess it's a bug in Xcode 6-6.1.

Update 2: This error came back. Exclamation marks next to every outlet. If I delete them I can't re-add them. Can't create new outlets. Also can't give a view controller a custom class. I really just want to make some progress on an app, but this issue keeps recurring. Really just can't stand it anymore. Any help would be appreciated.

Dale Townsend
  • 671
  • 3
  • 13
  • 25
  • 1
    I've had this problem extensively with each version of Xcode 6 since about beta 3. It's still not fixed in the GM Seed, from what I can tell. It's super annoying, but using Xcode 5 to hook up IBActions and IBOutlets is my current workaround. (Note: I've yet to upgrade to Xcode 6.0.1, but will do so in the next few days as time allows.) – mbm29414 Sep 19 '14 at 20:39
  • 1
    Really annoying bug. I'll try 6.0.1 or 6.1 and if that doesn't work will find a download of 5.1.1. – Dale Townsend Sep 19 '14 at 22:25
  • 1
    In my case I create a new project and move the files. Now it works properly. I don't know, but is something related to the `module` that never shows up something. – Ratata Tata Oct 20 '14 at 21:54
  • Sometimes it seems that the connections are gone, but actually are connected. If doesn't allow you to connect them, try to drag with the right button from the small circle (left of the IBOutlet property) to the IB. Also, try to download Xcode 6.1 and close Xcode. Finally go to product and hold Alt, the clean option will change to clean build folder...try that – jomafer Nov 13 '14 at 12:22
  • I have tried all of those things. The project builds and everything works fine, but when I disconnect an outlet I can't reconnect it. – Dale Townsend Nov 13 '14 at 21:17

15 Answers15

23

Duplicate of: Xcode 6: can't connect any IBOutlet to ViewController but here's the trick:

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... Unfortunately, in some cases, mine actually, all the connections get lost again when XCode is closed.

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 !

pkamb
  • 33,281
  • 23
  • 160
  • 191
Jerome
  • 915
  • 8
  • 17
  • 1
    This has worked for me twice now. Once (I think) after performing an Xcode upgrade, and again with brand new class files and a brand new xib file. It sucks that we have to jump through hoops like this just to fix a problem that shouldn't be happening in the first place. – Phil Ringsmuth Feb 13 '15 at 04:27
  • 1
    I had this problem right now with Xcode 6.3... Your solution worked. Removed reference of the controller source files, then re-add them. This is a poor bug, Apple... – Jonny Jul 05 '15 at 02:35
  • Just had to do this in Xcode 9, has anyone filed a friendly Radar yet? – alfwatt Sep 23 '17 at 20:28
  • Not me, never had to do it again :/ – Jerome Sep 26 '17 at 06:57
  • Issue still exists in Xcode 11. Removed and re-added the Custom ViewController class to fix – vee Feb 11 '20 at 23:43
7

I had the exact same problem and what was breaking my storyboards was the fact that my project was inside the folder /Dropbox (MyName)/projects/

Apparently something about the name of the dropbox folder with spaces and ( ) was BREAKING my storyboard completely, try what I did and move your project completely to another folder and see if that helps :)

Salvador Mosti
  • 171
  • 2
  • 5
5

I had the same problem, changed the class under identity Inspector > Custom Class to something else, saved it and then set it again to the correct one, after doing that the connections appeared normally.

fizampou
  • 717
  • 2
  • 10
  • 29
  • 2
    I can't even change the class for the UIViewController. If I create a new UIViewController class and try to change the Custom Class in the storyboard, that new class doesn't show up in the list. I haven't been able to make any progress on any apps for weeks now, so this is really annoying. – Dale Townsend Nov 29 '14 at 09:03
4

I had this issue with a Swift UIViewController subclass. I had removed the original view that IB created for me, and added a new view—which I was unable to connect.

I went to the Identity inspector for the File's owner, and tried to re-enter it, thinking that maybe it had been modified somehow. Oddly, the class name did not autocomplete. It seemed like XCode was unable to actually see my class.

I tried removing and re-adding both the .swift and .xib files, to no avail. XCode would allow me to manually type in my owning class name, but it would not autocomplete. It seemed to think it didn't exist, or wasn't valid for this context.

Looking back at my code, I had something like the following:

extension SomeViewController {
    func foo() -> Bool {
        return false
    }
}

class SomeViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
    }
}

It compiles just fine, but on a hunch, I removed the extension. I saved the file, went back to the .xib, and was able to set the File's Owner identity with autocompletion again. I was also able to wire up the view.

It would suck if extensions always broke things of course, so I tried again, this time with the extension after the class:

class SomeViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
    }
}

extension SomeViewController {
    func foo() -> Bool {
        return false
    }
}

Everything still worked in IB. To sanity check, I moved the extension back ahead of the class definition, and things were again horked.

I took a look a the *-Swift.h generated by XCode, and at least relative to the affected class, there seemed to be no differences—regardless of where I put the extensions in the Swift file, they were always declared after the @interface definition for the actual class in the header.

So, long story short, in my case this was due to Swift extensions (I say extensions because my actual code has many) coming before the class definition. I moved them after the class definition, and the problem went away.

Cora Middleton
  • 956
  • 7
  • 13
  • First tnx very much for detailed explanation. Same problem still exists in Xcode 8.3.2. Slow compile time is a problem but this, this shows me Apple does not know even how to compile. I am furious. – ergunkocak Apr 21 '17 at 10:11
  • Yep. Swift UITableViewCell subclass namespaced inside an Extension: Interface Builder cannot find the IBOutlets. – pkamb Jan 18 '19 at 04:33
2

For me I had to remove the reference and add back to my project the -XIB- file for my view controller. Simply removing the view controller .h/.m did not reset the outlets, but removing the .xib and adding it back did!

Will
  • 1,697
  • 17
  • 34
1

I have this problem only with @protocol defined IBOutlets if I don't redefine them in the implementing class.

Probably the only thing we can do is file a bug.

Rivera
  • 10,792
  • 3
  • 58
  • 102
1

Why dont you update your xcode 6.0.1 to xcode 6.1, Apple have fixed many bugs.

Download Xcode 6

  • 1
    I am running 6.1. I had the problem in 6 and 6.0.1, and updating to 6.1 temporarily fixed the problem. Then a few days ago I opened a project and it lost the outlet connections. – Dale Townsend Nov 13 '14 at 21:09
  • I'm getting it with 6.2. Repeatedly. So updating to 6.1 doesn't sound like a particularly plausible solution. – thund Apr 21 '15 at 00:30
1

Do you get the same issue if you connect the actions/outlets in Interface Builder instead of the assistant editor? For actions try control dragging from your object in IB to your first responder object (or whatever you have your class set to).

  • 1
    Yes, I was getting the same issue. It's just fixed itself, and I didn't change anything. Here's hoping this bug is fixed in Xcode 6.2. – Dale Townsend Nov 17 '14 at 02:42
1

@robb actually discovered the fix for this, but the issue he found was that the group in the project that mirrored a folder on disk used a different case.

So if the project group was Broken/classone.m

and on disk it was broken/classone.m

Interface builder could not find the files. Renaming either the group or the folder to match case resolved the issue.

1

I was having the same issue but it was because i changed the name of the view controller in the Project Navigator to MapViewController but its name stayed the same (ViewController) in the code. once i changed it, it worked

Yu.
  • 11
  • 1
0

I've had this same problem since using XCode 6.1, answers above didn't work for me. (removing/re-adding my class files, changing the class to something else and then changing it back. The only thing I didn't try was creating a new project from scratch).

I noticed by accident that my 'Application' placeholder within the MainMenu.xib had somehow got its class set to NSObject. Changing that to NSApplication seemed to clear the 'does not have an outlet named' problem from all of my other objects.

  • Where do I find this `'Application' placeholder`? – Iulian Onofrei Mar 12 '15 at 11:05
  • In the outline sidebar to the left of your mainmenu.xib main view. At the top: Placeholders>File's Owner, First Responder and Application – Shiela Dixon Mar 13 '15 at 12:05
  • Can't find it. It's a xib file, and not a Storyboard, could that be the problem? I found `First Responder` but not `Application`. Is it in the right sidebar? If yes, on which tab? (File inspector, Quick Help inspector, ...) – Iulian Onofrei Mar 13 '15 at 13:06
  • I have just noticed that this particular question relates to iOS wheras my answer relates to the same problem with an OSX project. My apologies, I'll paste my answer into one of the similar OSX questions, maybe a moderator would like to remove my answer from this question once you've seen this answer. – Shiela Dixon Mar 14 '15 at 13:50
0

I updated my project from Xcode 6.x to Xcode 7.x about two months ago without any issues. But then this morning I ran into this bug. I tried pretty much everything on this page but nothing worked. But then Justin Middleton's solution gave me an idea.

When I switched my project from the 10.9 SDK to the 10.11 SDK, I decided I wanted my code to remain backwards compatible just in case I had to revert back to Xcode 6.2. So I put Preprocessor code around several of my object declarations, e.g.:

// This caused the (!) problem in Interface Builder

#if( MAC_OS_X_VERSION_MAX_ALLOWED > MAC_OS_X_VERSION_10_10 )
@interface CLChatWindowController : NSObject <WebPolicyDelegate, WebUIDelegate, WebFrameLoadDelegate>
#else
@interface CLChatWindowController : NSObject
#endif
...


// Removing all the Preprocessor code fixed the problem

@interface CLChatWindowController : NSObject <WebPolicyDelegate, WebUIDelegate, WebFrameLoadDelegate>
....

Once I removed all the Preprocessor code, the (!) characters in Interface Builder disappeared and everything went back to normal. Hope that helps someone.

philbert1
  • 143
  • 6
-1

Xcode 6.3.2. Similar issue. A project(s) that i've been working on suddenly 'disconnects' IBOutlets and shows the error

view controller does not have an outlet named (subview)

The project still builds and works and if you hover over the IBOutlets in code it thinks there are still connected.

I've nailed this down (at least in my case) to an issue with storing projects on dropbox (similar to an above post). The fix for me was super easy:

Drag the project folder off of dropbox to your desktop. Then drag the project back into dropbox.

This solution has fixed numerous projects with the issue.

Jay
  • 34,438
  • 18
  • 52
  • 81
-2

Try to add the header file to the project, if it's missing.

ABCD
  • 7,914
  • 9
  • 54
  • 90
-3

I had this in Xcode 7.0.1 on a swift project. Specifically, tableview cell connections were broken (permanently) while other things still worked. Deleting derived data, rebooting etc - nothing worked.

My solution ended up being:

  1. Close xcode project
  2. Delete derived data for project (Window->Projects)
  3. Rename the entire project/source folder, ie. project -> project-1
  4. (Update source-management bookmarks like sourcetree as required)
  5. Open project in xcode (from finder): notice that the storyboard and a few other files are in red. Delete the references, re-add them. Boom, it works.

Note that deleting the reference to the storyboard and readding it, even with deleted derived data, was not enough. The rename of the entire source folder was necessary for me.

xaphod
  • 6,392
  • 2
  • 37
  • 45