How do I correct the fact that my .h file is linking its IBOutlets to a XIB file from another project?

I just had the same problem. What solved it for me was to close both projects, delete the derived data from both and then reopen the destination project.

I agree, it's a crazy problem.


If you copy the view controller code from one project into another project you will notice a strange thing happening with the outlet. It is referencing the view from the first project without you ever connecting any outlets.

enter image description here

If you left click the little circle and click the reference link you will even be taken to the storyboard view in the other project. Trying to figure out how to get rid of this reference can drive you crazy.

Well, the good news is that there is really nothing for you to fix. You didn't copy over some deep, hard to find referencing link. Xcode is just getting confused because the View Controller and the outlet name are the same in both projects. Basically just ignore what that little circle says. You can close the first project and Xcode will figure things out eventually. Right click your views in the storyboard to see what referencing outlets really exist in the current project. (See my fuller answer for more details.)

No need to delete Derived Data. That doesn't solve the problem anyway. Just try opening both projects at the same time again and you will get the same strange behavior.

The way I figured this out was to separately create two new projects that had view controllers with the same name and a referencing outlet with the same name. I never copied anything but Xcode showed one was referencing the other. Like I said, ignore the little circle.


I'm sure that this problem could happen and I fix it deleting the content of the Derived data folder of XCode.

I just want to add the steps of how to delete those files:

  1. Don't Delete the DerivedData folder.
  2. Go to preferences (Command ,) > Locations Tab
  3. On Derived Data you are going to see the path, clic the right pointing arrow (that will open that location in Finder)
  4. Close XCode
  5. Select all the files inside the DerivedData Folder (do NOT select parent folder) and (Command Delete) or move them to the Trash and then Empty Trash
  6. Open the project and you are done

I hope it helps someone

Tags:

Xcode