XCode has lost associating from xib to .h file (MonoTouch) - xcode

When I am editing an XIB in XCode I don't get the associated .h file to show up in the assistant editor window. Other XIB's work fine.
This is a problem as it's the way I create outlets by dragging onto the assistant window. If I open the .h file manually in another window I can't associate an outlet this way either. The .h file exists.
Also, my project is MonoTouch and therefore I invoke the opening of the file from MonoTouch. I assume it's a problem originating in MonoTouch and not Xcode.
Someone please help, or I will be forced to learn Objective C soon and quit with this MonoTouch business.

Sometimes there is a different solution, such as when the controller file is RENAMED.
When this happens, edit the .XIB file with the Source Control Editor (right click on .xib, Open With->Source Control Editor), and make sure that all references to the name of the controller are correct and that the path and name of the .h file are correct.
Look in the "IBClassDescriber" element specifically. The "className" under the "IBPartialClassDescription" element and the "minorKey" under the "IBClassDescriptionSource" element must be correct. MT will generate a .h file with the same name as the controller.
After making the changes, save the file, choose Build->Clean All, then double-click the .XIB file to open it in XCode.
It may or may not work for you, but it worked for me when everything else failed.

As Stuart mentioned in his comment, deleting the /obj folder under the project which contains the .xib files, force MT to regenerate .h files

Came across the same issue and removing the /obj directory and restarting did the trick.
MonoDevelop 3.0.3.5 with XCode 4.4.
Was rather confusing as I am came across issue whilst on first MonoDevelop iOS Helloworld tutorial.

In my case, this issue has appeared when I change a namespace in .cs view controller file according to the file location. But after that, I caught this issue. When I have returned namespace to incorrect variant I got back my .h file.
Update:
You need to change the namespace in view.cs and in view.designer.cs, then Xcode .h file will be generated correctly.

Related

Xcode will not open the ViewController.swift source files

I am in the Xcode editor. I can view the Main.storyboard or edit most of the source files. But for some reason the [*]ViewController.swift files will not display in the Editor section. What is going on?
The screenshot below shows that after hitting "enter" on the SecondViewController.swift instead of opening it in the editor the experiments.js remains. The same thing happens for SecondViewController.swift. However other .swift files do open properly.
I had edited those *Controller files in the past so this is bizarre. Any tips?
Observe how the icons are dimmed in the two ViewController files compared to experiments.swift
This usually means that the files are not where Xcode thinks they are. Check the path in the Document inspector and if needed use the widget in the inspector to correct the path or you can add the files again from their current location.
Maybe you moved the files outside of Xcode during organising or refactoring to cause this.

Xcode suddenly corrupted my xib file

Last thing I did with it was adding a checkbox and creating an outlet using assistant view. Since then Xcode doesn't compile my project, gives me this error and I don't know what to do with it...
Do a complete clean and rebuild of the project.
Also, does your console log indicate any potential problems?
If that does not work and you have a backup, copy your backup to a new location and see whether you have the same problem.
If none of the above worked, then you just have to copy the xib and associated .m and .h somewhere, delete them from the project. Then re-add them. You can copy and paste the .m and .h but you need to remake the xib from the start then link all the outlets and actions.

XCode: Project Files no longer linked with project/storyboard

Recently, some revision was done to one of my projects and the project had to be re-imported from SVN. All of the files are there, but I get weird issues when trying to use some of the project files.
For example, when selecting a view in IB, the assistant view would automatically show the associated header file for that view. Now, there is nothing under the 'Automatic' tab in the assistant view.
Also, when trying to #import certain files and create instances of them, xcode returns the error Unknown type name
I seemed to have resolve the issue. I had to create a new .h and .m file and copy the contents of the old .h and .m into the new one. Once I set the view in storyboard to use this file I no longer received any errors.

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.

XCode 4 stopped highlight and recognizing UIKit classes on project

Hi i get problem with xCode 4.
I develope project with XCode4 on home and on work.
And i store it on my USB flash drive.
Today i get some problem.
I open xib file for add outlet to code and get next error "Could not insert new outlet connection: Could not find any information for the class named ..."
Class exist and property of xib file setted correctly.
Could not insert new outlet connection: Could not find any information for the class named
Ok, think i, i write code and the connect using Files owner.
Next step i open code editor of .h class file and try to write UI... and see nothing. i dont get list of classes UI types
Next i saw what XCode code editor does not highlighting classes of UIKit and else frameworks too.
But i dont have this error on another projects and on it project but on home computer.
Some body have same problem?
Try this: Close your project. Choose Window > Organizer from the main menu. Select the Projects panel. Select and delete all copies of your project from the list. Open the project again (Xcode will rebuild the necessary information).
This will not delete your project, but the index and other information Xcode discovers about your project. As I said, Xcode will rebuild the information as soon as you re-open the project.
We had a really similar problem happen to us and none of the help out there worked. What did end up fixing it was deleting the .m and .h file from xcode (resource only) and then dragging them back into the project from the project folder. It seemed to relink everything and make it work again.
Just add .m files in Compile Sources under:
<My Project>
-- TARGETS <My App Name>
-- Build Phase tab
-- Compile Sources
It fix the problem.
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.Don't worry, you will get all your connections back.
It will fix the issue.

Resources