Xcode doesn't autobuild new files - ios

I am trying to add a new class to my project on xcode.
The problem is that xcode doesn't auto complete anything when typing in that class, auto build anything or anything else for that matter.
When ignoring the auto complete, and typing myself, I later try to link my xib file to my class by "pulling the strings" and when I hit enter I get the notorious error message in red saying "could not insert outlet - could not find any information on class..."
I have tried deleting the Derived Data folder, restart xcode, deleting the files of the class I was trying to add, etc. Nothing worked.
What do I do?
I think I have an issue with linking - if I try to add the interface for the xib file, which I created to have a custom table row view, in an existing file already in the project, it all works wonders.
Any one see that problem before?
Thanks!

Choose the m file in your left panel, then choose the target in the right panel.If you already add the file to the target, then in your project build settings, set the search path to your folders. May be the folder that files locate is not the real file filer, it is just a group.

Related

Xcode not able to find project file

In my Xcode project there are other projects linked but somehow its not able to read the sub project.
As you can see MobiResourceManager.xcodeproj is shown in red. And thus the classes which uses headers inside it gives error. But I am not able to understand why its not able to show the project. Sometimes it doesn't show MobiResourceManager.xcodeproj in red but even then the classes using its header gives error of HeaderName.h not found.
The problem that I am facing is happening only in my system. I tried cleaning, deleting-installing Xcode, cloning the repository again but nothing works.
All the project file shown in the screen shot are sub project inside one main project.
Probably that red file was removed or moved somewhere else. Open Finder, locate the missing xcodeproj, then remove this one in Xcode and drag&drop the located one. If that red xcodeproj is inside your repository (what I suspect) then do not select to copy it to the destination.
If you cannot locate that red file, it means it is not added to the repository. For example, it could mean that you need to install it with git submodules or another way - depends on the project configuration.
Are you using the workspace? if yes then please open that file not xcode project file

Getting error after changing project folder name in XCode

When I created my project, I called it "Project1". Then, later I've changed it to "Project2" from the Xcode. I changed all "Project1" to "Project2", but now, when I compile my project, it looks for files in Project2/Project1/myFile.swift and I get the next error:
<unknown>:0: error: no such file or directory: '/Users/myusername/Copy/Projects/Project2/Project1/myFile.swift'
I need to make that it will look at
/Users/myusername/Copy/Projects/Project2/myFile.swift
without Project1 in the path.
How can I solve this problem? Also, I changed from Xcode Identity and Type section Location of my project.
Today I had the same problem when I renamed the folder containing the Xcode project and some parent folders of it.
In my case there where a .swift file shown with it's name in red in the list of files of Xcode (Navigator area). I think that this means that Xcode was not capable to find that file.
I selected that file (actually it's not a real file but a representation of it).
Then, in the File Inspector (Utility area), I clicked on the Folder icon and chose the file on Finder.
This worked for me.
Renaming projects in xcode in one of the most annoying things in iOS development. I assume you want to rename your app. I faced this problem once and figured out a simple, clean way to do it.
Go back to the point where everything worked.
Open project in xcode and click on the project icon in the project structure( first file)
Go to the info tab
Search for Bundle Name. Most probably it will automatically be set to $(PRODUCT_NAME) which is a shell variable that will set your app name the same as the project name.
Set it to whatever you want your app name to be
Done
Note : If you use custom URL Schemes this might produce an error when redirecting.
ALWAYS use git or some other SVN in your projects. This will come in handy in this kind of situations
Change you folder name in you finder "Project1" to "Project2"
Remove "myFile.swift" file from project (copy on Desktop)
Restart Xcode. Copy "myFile.swift" in project select "Copy file to folder" hope this will help.

Interface Builder could not open the document "MainStoryboard_iPhone.storyboard" because it does not exist

After an awfull mistake, I deleted most of the files in my project i succesfully managed to get them all back but I have encounterd ALOT of errors now, e.g. "Interface Builder could not open the document "MainStoryboard_iPhone.storyboard" because it does not exist." is one of them, I have checked the file in finder and its there, when I press the file in project navigator I can see the storyboard I created but when I run the project I keep get that error...
My project navigator looks like this: http://screencast.com/t/dNVioFQg9
And my info.plist doesnt work for some reason..: http://screencast.com/t/JyqV32Ugt
and these are my errors: http://screencast.com/t/GJHfGGwQgn0Y
I also followed the solutions in this thread but nothing helped..."Storyboard.storyboard" could not be opened
and
Interface Builder could not open the document ".storyboard" because it does not exist
Please someone help me!
I managed to fix my issue!!!! For all you who encounter the same problem, delete file one file at the time and put it back to the project map and then xcode, keep do that with all of the files and dont forget to press the file within the project navigator after you draged the file in there.
How i solved this very same issue:
go to ~/Library/Developer/Xcode/DerivedData/
delete the folder called ("yourApp's Name"-some xcode generated string)
build again.
Hope it will help some one.

XMPPFramework: trying to #import XMPP.h gives a "no such file or directory" error

Does anyone know how to set up the XMPPFramework for iphone?
I can't seem to figure this out despite the wikis, and the wikis look out of date.
My project compiles fine, but once I actually try to reference any of the framework's classes, I get a no such file or directory error when trying to build the project.
I have no idea what is wrong despite using a bare bones project to reduce any sources of error. I'm using Xcode 4.2
Appreciate any pointers.
Thanks!
Make sure that you DID NOT just drag and drop the XMPPFramework files into your project. Notice in the XMPPFramework wiki is says to copy the files into your project folder, and then add the files into your project. So, if your XCode project is called XMPPTest, there will be an XMPPTest folder wherever you created your project, as in /Users/johndoe/XMPPTest. Taking step 2 for example, you need to press the "option" key and drag the folder titled "CocoaLumberjack" into /Users/johndoe/XMPPTest. THEN you can drag the "CocoaLumberjack" folder inside /Users/johndoe/XMPPTest into your actual XCode project. When you do, you should be sure to check the box "Copy items into destination's group folder (if needed) and select the radio button "Create folder references for any added folders". You should make sure that the checkboxes inside the "Add to targets" box are checked.
There is no XMPPH.h file in XMPPFramework. You should include XMPP.h instead

How to rename an xib file in Xcode 4?

I renamed an xib file in Xcode4, just by highlighting in the project organizer and changing the name, but it seems to confuse the project. For example, if I add a new button to the view, it doesn't show up when I run the project. However, if I rename it back to the original name, it shows up. What's the correct way to rename an xib file?
Xcode can sometimes be very picky with name-changed XIBs; the way that works best for me is as follows:
Remove the reference to a XIB file from my open project
In Finder, rename the file(s)
Drag them back to the project
You may still encounter errors either side of this process - and on other occasions, renaming the file by a (slow) double click on said file will work.... for errors like these, I find that by going Project -> Clean will also help.
Keep us posted!
What I've done and worked like a charm is
dereference it from you project but not delete the files
Open .xib with a text editor and rename the class
Drag drop to project again
and voila!
I know sounds a little bit awkward but that'life. If someone else has something better please say it...
I had a much bigger problem in that I was renaming a project which also required that I rename a xib. This is by no means easy. My final problem was after renaming the xib the class no longer matched because the old class was still named in the renamed xib file. I took Martijn's advice and simply edited the xib file with a text editor and renamed the class. Then I had to dereference and re-reference the xib. That did the trick.
I know it is already answered though i need to add one more thing i have faced to ...
I tried to rename MainWindow.xib to Window.xib from context menu of XCode, then i changed "Main interface" setting to relevant XIB in PLIST file ... from that time whenever i was running my App i saw SIGABRT error (Product > Clean did not help, unfortunately) ... until i completely closed and reopned me VMWare.
So in case you use Virtual Machine then it is + 1 more suggestion to answer above - RESTART your VM.
Hope this helps ...
First close Xcode, and make a backup of your project folder. Then move into your project folder and rename every file and folder which contains OldName so that it now contains NewName instead.
In the project folder, run following command in a terminal, to update the contents of the files in the project:
find . -type f -exec sed -i 's/OldName/NewName/g' "{}" \;
Open the now-renamed project in Xcode and clicked Build -> Clean All Targets.
After that, the project (with the new name) will be built successfully.

Resources