views:

537

answers:

12

Sometimes IB will hold onto old or bad references, and I cannot seem to remove or edit them.

EDIT I have made this a wiki question with the intention of gathering more data on the phenomenon. Answers involving situations where other coders have encountered this are welcome.

This happened to me again last night with a table controller. When I created a spike project to try and reproduce the error, the system worked the way I anticipated. Then back in the actual project the bad behavior continued, even if I remove the xib file and all controllers involved.

Creating a whole new project with none of the original (problematic) xib and nib files worked correctly.

This question is not about the specifics of this incident but about this type of incident in IB.

Does anyone know more about this type of bad IB behaviour, and possibly a more stylish way to to eliminate it than nuking the project?

Note, removing the offending IB files and recreating them in the same project has not solved this for me in the past, only whole new projects.

Answers regarding examples of when/how this glitch has been observed/created are welcome as well.

A: 

Maybe not the answer you want, but here it is: Do not use IB! :-)

I had troubles using it too, even when reproducing exactly the steps as described in some Apple docs, trying multiple times from scratch. So after 3 days I just gave up and started doing everything programmatically, implementing my program in half a day. I have never looked back since. I only launch IB occasionally to look at sizes, so I can feed them into my code.

It will probably be less easy to update my GUI over time, but if your story is a real recurrent problem, I'm glad I parted ways with the beast!

squelart
The glitch I described has only happened a handful of times in the last year. Annoying as it is, I won't be ditching Interface Builder.
Ryan Townshend
-1: not using IB is like using horses instead of cars because of the smell
IlDan
@IIDan: Analogy fail. I'm not using IB because I couldn't make it work, not because of the smell...
squelart
+1  A: 

The only real suggestion I have is to file a bug report at http://bugreporter.apple.com/ with a reproducible project as the attachment; in my experience Apple do look at these things. That said, you say that re-creating the XIB in the same project didn't fix the bug. What about replacing the other end of the link; i.e. re-create the header file and use that new header with the existing XIB? Perhaps that's sufficient to prod IB into updating its model.

Graham Lee
A: 

When you say old or bad references, do you mean it is trying to link UI elements to outlets or actions in a class that no longer exist? If that is the case then go to the connections panel (cmd-5) and select the object in your nib file. It should show you all the connections. Any where the text is greyed out and have an exclamation mark should be deleted (hover over and click the x).

In IB, you are only connecting to a "promise" of what your class will be like when the app launches. IB normally only lets you connect stuff that can fulfil that promise, but if you change the header in Xcode there's nothing IB can do about it besides warn you.

Martin Pilkington
A: 

Try making a clean build of the code and then see if the old references remain in the xib

lostInTransit
A: 

You don't say if the problem has persisted across restarts, so I think it might be this issue: There is a rare bug in Xcode's build process where sometimes old versions of output files are stuck in the /tmp folder and won't get updated. IIRC, the easiest solution is to clean the target and reboot your computer.

Chuck
A: 

Are you saving the header files? Interface Builder parses the content of your header files on disk, not the unsaved files in Xcode's editor. If you add an outlet to a header file, and switch back to IB without saving first, IB won't see the new outlet.

Jon Hess
A: 

I had exactly the same problem with IB when I created a new project out of an old one. I can synchronize IB with the new .h files but IB still gave the removed references (from the old project) when I right-clicked the object ( the class name "MainController" was the same from the old to the new ) even though those references did not exist in the updated code at all.

"You don't say if the problem has persisted across restarts, so I think it might be this issue: There is a rare bug in Xcode's build process where sometimes old versions of output files are stuck in the /tmp folder and won't get updated. IIRC, the easiest solution is to clean the target and reboot your computer." I tried to clean the target but it did not work.

However, once I deleted the MainManu.xib and created a new one (there would be a bit work to design the interface by hand), the old references were gone.

Yushen Han
+3  A: 

I fixed this type of caching problem by clicking File > Read Class Files ... and pointing IB to my class files. Bingo, it read them fine, and everything worked. :-)

Louis St-Amour
A: 

I experienced the same problem. It happens when I open a project made with old Xcode version. Interface Builder does not sync correctly with Xcode. Yes, I can manually update the IB cache with the 'File->Read Class Files...', but even with this method garbage remains. I mean old IBOutlet and IBAction still shows up.

y5h
+1  A: 

I just had a project where this happened and I was banging my head trying to get it to update properly in IB 3.2 (732). I really did not want to redo the xib from scratch. I tried drag/drop of the *.h files, restarting, reloading everything and it didn't work. I also tried File->Read Class Files which didn't work. Strangely though, File->Reload All Class Files worked like a charm.

robottobor
Really? I'll check that out.
Yar
+1  A: 

I find that File > Read Class Files fixes it for a single nib file, however the nib doesn't remain in Sync with any future changes and the fix doesn't apply to any other files in the project either.

Restarting and/or clean building didn't help either, but new projects are fine. This has been happening to me in Xcode/IB ver 3.2.2 - so far the only solution has been rebuilding the code in a new project.

benz001
A: 

Just had this type of incident and fixed it by using XCode's refactoring to rename classes to different names. Seemed to get stuff restarted.

Yar