Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

xcode

This is a real 'WTF?' moment for me.

I copied some classes out from another project, including copy and pasting the code and some UIBulder components. What did NOT get copied was the XIB file (I went from XIB to storyboard).

My tab / swipe recognizers aren't activating, and when I drill down the only thing I can discover that can explain it is that somehow, someway, I'm hooking up against the XIB file. (When I click on the little button next to the IBAction/IBOutlet lines in the header, it shows me both the storyboard and the xib file as connected).

I'm not referencing that file anywhere that I can find, it's just somehow magically recognized in Xcode. I don't know what to do, how to fix this.

Anyone have any ideas?

Edit: The really annoying bit is that the file doesn't appear to be in my files list when I check there, I can't just delete the reference that way. And since it's referencing the file in the original project, I can't just delete it. (Any changes made in either project cause changes in BOTH projects; their both using the same xib file for some reason). I should be able to simply delete the reference to the xib file, but I can't find the reference.

like image 475
RonLugge Avatar asked Aug 22 '12 18:08

RonLugge


3 Answers

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.

like image 66
Suragch Avatar answered Nov 15 '22 04:11

Suragch


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.

like image 13
Matt Becker Avatar answered Nov 15 '22 02:11

Matt Becker


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

like image 3
Juancarlos Rodríguez Avatar answered Nov 15 '22 03:11

Juancarlos Rodríguez