.swift viewcontroller missing (!) - xcode

In my project navigator, a .swift file that connects to a viewcontroller has an "!" next to it and says that it's "missing".
When I click on the file, it shows the code for that viewcontroller, and my app works, but the title bar in the mainstoryboard for that viewcontroller doesn't match the file name.
I'm not sure what the problem is or how to fix it. Thanks!

Related

File's Owner 'view' outlet not showing

I created a project in Xcode 6 beta 2, which initial had a storyboard. I wanted to work with separated xibs so I removed storyboard and line related to storyboard from Info.plist and added several xibs. Now the problem is that I can't connect file's owner 'view' outlet (because it's not visible) to view from xib. First thought was that I misspelled name of the file's owner custom class name (from Identity Inspector), but I didn't. Also file's owner class is a UIViewController child. I don't know that the problem can be. Did some faced this issue ?
It's probable that you need to close Xcode, clean the project and try again. I created a new project without storyboards and I did the following:
1) I created the nib file.
2) I created the UIViewController class.
3) I opened the nib and selected the File's owner tab. Then I wrote the name of the custom UIViewController class.
4) Without selecting the file's owner tab on the Placeholders left bar (make sure of this) go to Connections inspector tab and you should see the view outlet.
Simply cleaning, quitting Xcode and re-opening fixed it for me.

After localization: Unable to find nib named ... in bundle path: (null)

I'm starting to get into Mac OS X development and I have a problem the solution to which I haven't been able to figure out for the last three hours (I've googled a long time).
Test application:
I have an application that has a MainMenu.xib, which displays a window - so far so good. I've created another XIB and NSViewController subclass that contains a view which I want to display within the main window. I use the following code to load the view and insert it into the main window:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
// Insert code here to initialize your application
self.compartmentViewController = [[SelectCompartmentViewController alloc] initWithNibName:#"SelectCompartmentViewController" bundle:nil];
[self.compartmentViewController.view setAutoresizingMask:NSViewWidthSizable | NSViewHeightSizable];
[self.compartmentViewController.view setFrame:[self.contentArea bounds]];
}
compartmentViewController is a property and self.contentArea is a custom view on the main window - like a placeholder.
This works fine so far.
Problem
Then I decided to check out the localization feature. I've localized a couple of strings and both XIBs. At first I was a bit confused by not seeing any localized values. That was until I found out I had to clean the project - since then I've been getting the following error when running:
2013-03-19 22:48:59.763 Vocab Box[10160:303] unable to find nib named: SelectCompartmentViewController in bundle path: (null)
2013-03-19 22:48:59.764 Vocab Box[10160:303] -[NSViewController loadView] could not load the "SelectCompartmentViewController" nib.
Suggested solutions I've tried to no avail
Cleaning the project doesn't help
Checking the build configuration - yes, the bundle resources seem to be ok
Yes, if I remove the localization for my subview and re-add the original XIB, things are fine again (though of course the view is not localized)
Help
I don't have an answer as to why this happens. But I had the same problem, and I fixed it by closing xCode and opening it up again, believe me.
Try the following :
select your project
select "build phases"
add the new xib in the "copy bundle resources"
I just had this same issue and was able to solve it by doing the following:
1) Select the XIB in the project navigator
2) In the File Inspector, uncheck any items under Localization (it will prompt you - make sure 'delete files from disk' is unchecked, and press Remove)
3) Manually add the XIB back into the project

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

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.
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.
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 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.
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:
Don't Delete the DerivedData folder.
Go to preferences (Command ,) > Locations Tab
On Derived Data you are going to see the path, clic the right pointing arrow (that will open that location in Finder)
Close XCode
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
Open the project and you are done
I hope it helps someone
unless the xib file is in the project. it should not have a link to it.
the xib file connects to the .h file. not the other way around.
You may want to remove the connections in the storyboard and re-connect them.
Also make sure that the storyboard is the UI being started and that the item on the navigation stack is actually the storyboard page. But you should be able to connect both the storyboard and the xib file to the class at the same time. You just cannot connect one IBOutlet to more than one object in a single ui component (e.g. two buttons on the storyboard cannot both be connected to #property IBOutlet UIButton *myCurrentButton you must have a separate IBOutlet for each connection. On the other hand, any number of actions can be connected to an IBAction. which is why you get (id) sender on each action.
I dont know if this is exactly what you are experiencing, but I hope that understanding helps you debug your issue.

Why can't I set a referencing outlet for my NSTextView in XCode 4?

I'm making a simple dialog in XCode 4 using the Interface Builder. I have three NSButtons, all of which are hooked up to their relevant IBOutlets. However I have an NSTextView, which I'd also like to hook up. I have the declaration for it in MyDialog.h:
#interface MyDialog : NibLoaderOC {
#public
IBOutlet NSTextView* tv;
IBOutlet NSButton* acceptButton;
IBOutlet NSButton* editButton;
IBOutlet NSButton* rejectButton;
}
#end
But when I drag the 'New Referencing Outlet' line over tv, it won't highlight. If I try and make a new outlet, it says:
Could not insert new outlet connection: Could not find any information for the class named MyDialog
I have tried restarting XCode, this does nothing. What am I doing wrong?
I noticed that .m file was moved inside en.lproj folder.
Just delete (reference only) the .m file from the Xcode and moved .m out of the en.lproj.
Add it again.It will fix the issue.
Don't worry, you will get all your connections back.
Although I'd still be interested in a proper solution, I fixed this by just manually editing the xib code to create the link.
This has the unfortunate side-effect of Interface Editor refusing to play nicely with the file (although all my manual edits were correct, and the code compiles and runs perfectly).
i got this bug in xcode 4.6.0. restarting xcode didn't fix it for me. deleting the derived data for the project, then restarting xcode did fix it.
delete /Users/myusername/Library/Developer/Xcode/DerivedData/MyProject
Another thing to check for is to make sure that if you have a custom class that you specify it under "Custom class" in the Identity inspector of Interface Builder.
So for instance if you have the following declaration
#interface MyViewController : UIViewController {
#public
IBOutlet MyCustomView* aCustomView;
}
#end
Make sure you add that into the inspector as pictured. Otherwise I've found that you won't be able to hook it up.

IBAction not appearing in xib file (A)

I have added a normal file, and in the .h file I've added the following code:
-(IBAction)PushButton;
My problem is, the action doesn't appear in the xib file when I go into "File's Owner".
I only have the problem with my "A" files. It works perfectly fine in the "M" files.
Any ideas?
May you have not set the class name in the xib

Resources