Can't Recreate Deleted Outlets?

Whenever I delete a Swift 3 outlet, I'm unable to create a replacement for it. The only way I've been able to recover is to delete the ViewController and its swift file, and then create a new ViewController and related swift file. As you can imagine this is a real pain in the fanny! Plus, Xcode has to be more flexible/smart-enough to handle outlet or action deletions and replacements!


If I'm doing something wrong, i'd like to know, so I won't have to go thru this. If there is a work-around, I'd like to know this, too. The reason I delete outlets is usually for naming errors (I use a naming convention to easily allow recognition the control object the outlet is referring to) or I change object and then go back to the original objectt type. Whenever an outlet is deleted, checks are made ensure the outlets in the Connection Inspector are deleted, too. The message I get on attempted re-creation is in red, "Could not insert new outlet connection: Could not find any information for the class named (name of the VC's class).


HOW DO I FIX AND GET AROUND THIS PROBLEM NOW and IN THE FUTURE?. I sure don't want to go thru another VC/VC.swift replacement!

Accepted Reply

If you delete accidentally, either in IB or in code, and realize rapidly, undo works well to restore everything.


Otherwise, it may be more difficult: if you deleted in the code (or just change the name of outlet) you need to clear the connection in IB and then perform an option clean as KMT advised.


To rename an outlet I usually do:

- delete the connection (right click on object in IB and click on the x in front of outlet name)

- rename

- to establish the connection again, it may not work by dragging from the bullet in code to the object in IB; but it (usually) work by ctrl drag from object in IB to the name of the outlet in code.

Replies

An oft reported bug I guess, so you're not alone.


After deleting an outlet, did you try an 'option-clean build folder' to see if that moves thing along? Deleted derived data?


If still no joy, try restarting Xcode.

If you delete accidentally, either in IB or in code, and realize rapidly, undo works well to restore everything.


Otherwise, it may be more difficult: if you deleted in the code (or just change the name of outlet) you need to clear the connection in IB and then perform an option clean as KMT advised.


To rename an outlet I usually do:

- delete the connection (right click on object in IB and click on the x in front of outlet name)

- rename

- to establish the connection again, it may not work by dragging from the bullet in code to the object in IB; but it (usually) work by ctrl drag from object in IB to the name of the outlet in code.

Hey Claude, What I've found is that no matter what object place on the VC screen, I can't make any corrections to them. I get the message described in my original post. By the way, I tried the 'clean folder' method in addition to the 'clean' option, and none solve the problem. So, once again, I'm forced to rebuild the VC and VC.swift files. This is a real pain in the fanny!

Claude,


Since I'm forced to recreate the scene with the connection problem, do I need to do the VC AND VC.swift, or can I get away with re-creating the VC only. It appears the problem is in the VC, and not the VC.swift. However, it could be under the covers of the VC.swift, too.


Any suggestions?

Thanks for your responses, Claude. Probably what I learned most is be EXTREMELY careful when working with connections, because Xcode is broke when it comes to making any changes to them.

The only workaround I can offer others for the situation is to type in your link in your viewController or windowController file:


e.g.


@IBOutlet weak var taxFormPopUpBtn: NSPopUpButton!


then, in Interface Builder, right-click Placeholder for the File's Owner and you should find the Outlet there. Drag from that outlet to your control/view to make the connection.


I cannot see why Interface Builder stops working the other way round. I've looked at the source code and cannot see any remnants of the old code.