Ok so some how 2 of my classes had ended up in a weird directory
projectname>projectname.xcodeproj>
In my infinite wisdom I tried to transfer these to the proper directory were the rest of my classes are (projectname directory)
However now I cant compile due to it not being able to find certain files
what file can I edit to check to see where it's looking for these files?
UPDATE 1
in response to the first answer I have tried readding the files. which has netted me some different errors. Specifically that Cameleon-Prefix.pch, no matter how many times I re add it always shows red.
A quick fix for this is to delete the files from Xcode, but in the confirmation dialog, choose to just release the references. Then add the files again (from the File menu Add Files… item).
If you want to see where Xcode expects to find the files, choose the file in the navigator pane on the left, and set up the right hand pane with this configuration.
And from there you can click on the detail disclosure buttons to see even more.
Edited to add
Make sure this is the same file pointed to in your build settings:
Do a similar search for pch to make sure the same thing goes with the pch file
Related
I'm using Xcode 8. I recently inherited a project with several hundred files (including source and image files). I rearranged them on my local drive and the file names (appropriately) become red in the folder list on the left side of Xcode. I selected files/folders in this folder list, click on the "Hide or show Utilities" button to display the "Identity and Type" pane on the right side of Xcode, clicked on the little folder icon next to the Location, and selected the files'/folders' new locations. The text in that pane was updated to the new location and the file/folder names changed from red to black. So far, so good. I did this to all of the file/folder names until none of them were displayed in red.
However, when I go to build the project, I get numerous warning messages similar to, "image.png /Users/Me/Project/images/image.png is missing from working copy." The path shown in the error message is the file's OLD location. When I look at that image in the file list, it is displayed in black. When I select that file and look at the Full Path in the pane on the right, it shows the file's current location (e.g., "/Users/Me/Project/images/newfolder/image.png"). I'm unsure where in the project the old location is being stored. FWIW, I've tried Cleaning the project...
Thanks for insights.
So here is an approach that is perhaps not for the meek, yet it is something I do more often than one would expect to fix Xcode project files. I tend to be the one designated to do this on the teams I work with ... manually editing the project file. The .xcodeproj file is really just a special folder. The actual project file is project.pbxproj.
First back up the project file. Your choice on if you want to do the complete .xcodeproj or just the project.pbxproj.
Use your favorite text editor and open up the project.pbxproj file.
Search and replace the prefix to your path. For the sake of this exercise, you should try and keep your path as similar as possible to make it easier. For example, if the hardcoded path is /Users/Me/Project/Images/newfolder/image.png and all prefixes are generally "/Users/Me/Project", you can just do a search on "/Users/Me/" or "/Users/Me/Project" (the latter if you want more safety) and replace with "/Users/You/" or "/Users/You/Project". Note I am not searching on "Me" and replacing with "You". You want to search and replace but as controlled as possible.
Once done, save and open the project. If the project doesn't open at all, it means you messed something up. Start over. Note that changing the paths should not be sufficient to break the file. It will probably mean you accidentally added or deleted something.
If the project file opens now build. It should hopefully build.
Okay, so that gets you into a buildable state. Now you really want to fix things. Whomever did the project was a knucklehead for using absolute paths.
This next part will be tedious. There are probably ways to do this manually, but I'll leave that to an exercise for the reader right now. In file inspector within Xcode, you will want to change files to be anything but "Absolute Path". Here is an example, you can see the location is "Relative to Group".
Essentially you are going to have to around to Groups and files and fix things up to not be absolute. Make sure you backup incrementally and can build.
Wait, but unfortunately there is more. You'll then need to go into Build Settings to see if things are absolute paths. Then you'll need to decide how to adjust for that. For example, it is not uncommon for 3rd Party frameworks to be added with absolute paths.
Or I suppose if you want to, you can just get it working and skip the latter part of this and damn everyone else...
I just merged one of the feature branches into develop branch, and since then, when I open Xcode, the .xcodeproj file seems lost, all files in the project navigator are gone also. click on the .xcodeproj file I get the following alert: The file couldn’t be opened.
This is although I am adding .xcodeproj to the .gitignore file across all the branches. Have you encounter such situation?
This might be caused by unresolved merge conflicts. In that case the XML structure is broken, so Xcode can't read it.
In that case you can try this:
In finder right click on the .xcodeproj and choose 'Show Package contents'.
Open project.pbxproj in an text editor (this is the actual project file, and has to be valid XML)
Check for merge conflicts (look for <<<<<<< and >>>>>>>) and manually resolve them (be careful!), and ensure the file has valid XML format
Save the file
Try again opening the .xcodeproj with Xcode
There might be better ways of resolving the conflicts, but this worked for me multiple times.
You also might want to check out this question: How to resolve merge conflicts in Git?
Basically, in a project if more than one developer are working and one developer has added some files(it may be .h,.m or any .png) and commits the project including .xcodeProj in source control management.
But due to some reason developer removes files or images from the project and also removes the use of those files or images from the project but forgets to commit the.xcodeProj project file.
If another developer checks out from the source control management and runs the application,he would get error messge error:path file/image name:No such file or directory.
So to avoid the error to run the application at our end successfully we can follow below steps
Right click on projectname.xcodeproj and click on showpackagecontent.
There we will get another file as project.pbxproj.
Open that file on text edit and remove the lines where the file or image has been mentioned.
Save the file.
And finally run the application it will work.
I know this is an old thread, but I had this issue today. I initially shrugged this answer as I don't have multiple users on the project, but I:
right clicked on the .xcodeproj and chose 'Show Package contents'.
From here, I noticed I couldn't open the project.pbxproj. I 'didn't have the necessary permissions', so I...
changed the permissions on the file to everyone can read/write, and then I was able to open the project without issue in Xcode.
not sure where this got crossed for me, but in case anyone sees this and has a similar issue and it's not a merging conflict.
Faced with the fact that the above methods did not work for me, my reason was this: when merging two files, the structure inside of project.pbxproj file overlapped and was broken, all I did was again thoroughly scan the conflicting sites for the correct syntax {some code} , availability ';' etc.
There were around 200 files I had to delete in my Xcode project (and yeah, they were deleted properly), and now I have to copy 200+ files are supposedly replace the ones I just deleted.
I keep getting "Multiple errors occurred while copying files". The Xcode window doesn't show the newly-added files, but if I explore the project folder using the Finder, I can see that the files were indeed added - well, there most likely was a certain file that could not be copied and thus caused the error. Problem is, I have no idea which one nor why.
Now then, is it possible to get Xcode to tell me what the problem is rather than telling me there is one?
Edit: Okay, I did discover that some of the new files shared the same name as some files that were not listed in Xcode, which explains the error. However, I am still interested in knowing whether there is a way to know that the "Multiple errors" actually are whenever Xcode says t his.
When Xcode finds a duplicate file, it generates this error, and then it fails to add references for the files that it did manage to copy.
Rather than deleting files from the finder and starting over, you can do this:
Open the Finder for your project, where your source files are located
Command-click the ones for which your references are missing (and if you click others, it won't really matter)
Drag them into Xcode. When the confirmation dialog comes up, unset the "Copy items into destination group's folder (if needed)" checkbox. This will tell Xcode to make references only.
I deleted the files from finder and then added again the files via Xcode, that worked for me.
This error sometimes occurs when the code is not merged properly. The missing files will not be available in Xcode but once you open the finder containing this project, you will be able to spot the missing file.
The simplest way to add these missing files back to the project is:
1) In your Xcode, navigate to Build Phases Tab.
2) Under Compile Sources, tap on '+' to add back the missing file.
Sometimes the missing files will be greyed out in the build phases, just tap on '-' and add them back.
For me this is worked. I tried to add files which are already in my bundle. So make sure you are not adding files which are already added. I hope it helps someone.
Coming from a background of Visual Studio I had no idea how good that IDE truly was until I had to work with Xcode. One of the more pressing oddities that it has just thrown up is the following.
I'm upgrading a project to a retina display and so have to add a bunch of new #X2 files. This is fine, I have the files and I go into Xcode, choose the project group where I want to add them, select them all and click 'Add'.
"Multiple errors occured" Xcode helpfully blurts and then returns to whatever it was doing before. No break down of what those errors might be, or what actually happened or why.
So I do some looking and some of the files are actually in the directory but Xcode ignores them, I can't figure out a way of adding them (it says they're already there!) but they won't appear in the xcode project.
Can I 'refresh' xcode so it looks in the directory and shows them?
==============================
PS. While I'm here and can rant a little, anyone with a VS background now using Xcode, am I wrong in thinking the following points are hugely annoying:
1) The debugger - frustratingly slow.
2) The file explorer - can't easily sort by name
3) The file explorer - column on the right listing the file names doesn't change the file highlight when you move from file to file within the editor window.
4) Adding files to a project - see above!
Some of these probably stem from lack of experience with the IDE but still, they irk.
Files in the XCode directories don't necessarily have to be in the project.
For some reason, XCode doesn't like overwriting files, and that's the warning message that I usually get when this happens too - "Multiple errors occured."
What I suggest you do is remove all of the #2x files from your project directory, and add them back into XCode using "Add Files..." Make sure you select "Copy files into project directory if necessary" though, otherwise they will just be referenced to their current location on disk.
As I write most of my code using MacVIM, I need to add the new files to the XCode project in order to compile them into the executable. Today however I encountered an implementation file (.m) which XCode won't allow to be added. It appears light gray in the appropriate finder window as if it were already included in the project, but when I try to build, I get a linker error, stating that the symbol defined this implementation file could not be found. The corresponding header file could be added without problems.
Any idea what could have caused this problem?
Btw. I deleted a former version of the same file from the "Classes" tree before, as well as many others which were successfully re-added.
I think I saw a similar problem once with an old version of Xcode. IIRC the way I resolved it was to:
rename the source file (temporarily)
add the renamed file to the project
do a "Save As..." on the renamed file to get it back to the original name
The file is probably already in your project, but not in the target you're building. Use the Detail view and Search bubble to find it, Get Info, and in the Targets tab of the info window, check the check box for the target you're building.
The other answer (removing and re-adding) works because you end up removing it from the project, then when you re-add it, it's added to the current target by default.
I found that deleting my pbxuser file from inside the .xcodeproj solved the problem for me. There were references to the files I couldn't add in there, surprisingly. This has happened to me many times over the years.
Another trick is to:
Move the file into a different directory
Add it to the XCode project from there
Move it to the desired location
Select the file in Groups & Files
Choose File > Get Info from the menu bar. The full path will appear in red.
Press the Choose... button and select the file at the new location.
If you are using Xcode 4, you can do the following steps to add an existing file into your target:
1) Select your file in "Project navigator" view (aka. click your myfile.m file in the folder tree of Xcode)
2) Click menu item "View" => "Utilities" => "Show File inspector" (or use the shortcut "Alt + Command + 1)
3) There is one section called "Target Membership", check the target you want
I fixed this by deleting the .xcuserstate file and restarting the project. I am using a workspace file, for all it's worth.
You can find any and all referencing files via
grep -r -h [NameOfFileThatYouAreTryingToAdd] *
from within your project directory.