Parad0x13
Parad0x13

Reputation: 2065

Xcode Includes .xib files that have been deleted!

I have a problem with Xcode that I can't seem to resolve. I have a view controller lets call "foobarViewController", there was a "foobarViewController.xib" to accompany it. In this controller I splish-splashed with the view to make it look the way I wanted, but decided to do it pragmatically. And so I deleted the xib from the project, cleaned all targets, restarted xcode, restarted COMPUTER, deleted the old build folder even and STILL when I compile the view includes objects that were only in the XIB file.

What is going on here?

Upvotes: 20

Views: 8694

Answers (9)

Eyal
Eyal

Reputation: 124

Sometimes it is very annoying to remove the app from the device/simulator, especially when you have saved data and configuration.

To solve this issue, for every View Controller for which you removed the .xib file add the following code:

-(NSString*) nibName
{
    return nil;
}

Upvotes: 0

Jones Agyemang
Jones Agyemang

Reputation: 1516

In iOS Simulator Menu > Resent Contents and Settings

Is sufficient.

Upvotes: 0

Abhay Singh
Abhay Singh

Reputation: 586

Xcode caches the xib files. Possible solutions are:

  1. If you rename your view controller the view will contain only the newer xib file. Older elements will not be shown.

  2. In case you decide to get rid of the xib file and make the view programmatically you can override loadView method in your viewController. Over-ride this method only when you don't want to load the view from a xib file and want to create the view programmatically.

    • (void)loadView { self.view = [[[UIView alloc] init] autorelease]; }

The problem with deleting the app from device/simulator and then building it again: Users who already have the app on their device and install newer version on top of it will continue to see older xib.

Upvotes: 1

Tieme
Tieme

Reputation: 65389

check out this post: How to Empty Caches and Clean All Targets Xcode 4

"Command-Option-Shift-K to clean out the build folder. Even better, quit Xcode and clean out Library/Developer/Xcode/DerivedData manually. Remove all its contents because there's a bug where Xcode will run an old version of your project that's in there somewhere.

In the simulator, choose iOS Simulator > Reset Content and Settings.

Finally, for completeness, you can delete the contents of /var/folders; some caching happens there too." - Matt

Upvotes: 3

sram
sram

Reputation: 995

In XCode4, Command-Option-Shift-K should do the job. Same as product, press the option key, now the option "Clean" will change to "Clean Build Folder ..." select that option.

Upvotes: 2

Lily Ballard
Lily Ballard

Reputation: 185671

Did you delete the app from the simulator? When Xcode installs a development build, either in the Simulator or on the device, it doesn't delete existing files. It simply overwrites files and adds new files. This means that if you delete a file from Xcode, it will be left in the already-installed built product. The solution is to delete the product from your simulator/device before installing.

Upvotes: 9

howanghk
howanghk

Reputation: 3090

The AppDelegate load the MainWindow.xib, and in the MainWindow, it include your foobarViewController.xib, therefore your problem occurs. Try editing MainWindow, point it to your controller class instead of including the xib.

Upvotes: 4

Jonathan.
Jonathan.

Reputation: 55554

Try these 3 things:

  • Delete app from simulator

From Xcode:

  • Build Menu -> Clean All Targets -> Check both boxes -> Clean
  • XCode Menu -> Empty Caches... -> Empty

Upvotes: 27

TigerCoding
TigerCoding

Reputation: 8720

Are you sure it was deleted? You may have only removed the reference to it. Open the project folder and make sure it isn't there. Better yet, do a search in spotlight for the filename.

If you can't find the file, it's still unresolvable, and you made the view controller programmatically, try pasting your code into a text editor, delete the classes, and re-make it and paste the code back in.

Upvotes: 4

Related Questions