8 Replies
      Latest reply on Jan 31, 2019 5:42 AM by FredNorthrop
      T P Level 1 Level 1 (0 points)

        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!

        • Re: Can't Recreate Deleted Outlets?
          KMT Level 9 Level 9 (14,015 points)

          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.

            • Re: Can't Recreate Deleted Outlets?
              T P Level 1 Level 1 (0 points)

              KMT, thanks for your response.  Yes I used the "Clean" function, which I find myself doing to much in Xcode.  Yes I've restrted Xcode and even rebooted my laptop.  No joy from any of these actions.

               

              I don't understand your comment, "Deleted derived data?".  What is it, where is it, and how do I do it?

                • Re: Can't Recreate Deleted Outlets?
                  KMT Level 9 Level 9 (14,015 points)

                       > Yes I used the "Clean" function

                   

                  A simple clean is rarely useful and not what we're suggesting.

                   

                  Instead, hold the option key, then use the Product menu and choose to 'clean build folder'.

                   

                       >I don't understand your comment

                   

                  It's manual, now, so don't bother if you don't already understand.

              • Re: Can't Recreate Deleted Outlets?
                Claude31 Level 8 Level 8 (5,735 points)

                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.

                  • Re: Can't Recreate Deleted Outlets?
                    T P Level 1 Level 1 (0 points)

                    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!

                    • Re: Can't Recreate Deleted Outlets?
                      T P Level 1 Level 1 (0 points)

                      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?

                      • Re: Can't Recreate Deleted Outlets?
                        T P Level 1 Level 1 (0 points)

                        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.

                      • Re: Can't Recreate Deleted Outlets?
                        FredNorthrop Level 1 Level 1 (0 points)

                        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.