Files in Xcode not working (names in red) - ios

I renamed my app folder to try and change the name of the app because it didn't work in the project navigator and when I did so, all files came up in red. I have tried to fix it by renaming the files back to how they were but it still doesn't work.
Any help would be greatly appreciated.
Link to dropbox: https://www.dropbox.com/s/omvo0saff0z9ncc/TicketekApp%202.zip?dl=0

If files marked in red, they are "not found" by Xcode.
You either moved or deleted them within File Finder, outside Xcode.
Delete the red marked files within XCode, then add them again to XCode.
This will solve your problem.

I solved this problem as follows:
click on the Group name in which file names are showing in red colour in the Xcode navigation area (Navigator) on the left side. In the Utility area on the right side in Xcode open up File Inspector tab. There is a Field named Full Path:, click on the arrow placed last to the path. You will have popup window showing your project path. Change The Group Folder in which you already moved your files from Finder.

In my case after moving the projects to a new folder and fixing each file location, the project compiles properly but the files names were still in red.
The problem was that the files were grouped in groups. The group was the cause of the red names of the files. So I added new groups, with identical names to the old ones (Xcode allows to do it since it does not know were is the old group), moved the files from each group to it's new group and deleted the old groups.
Now all the red names are gone.

For me, I had to make a new folder again and add everything back

Another reason for this problem might be your project.pbxproj file. In my case, after doing a git merge, one of the PBXGroups missed a line of code. After comparing it to the others and adding the missing line, problem disappeared.

In my case I had a contents.xcworkspacedata file that had the below, an absolute pathname to a couple of files (just 2 out of about 40). When I checked the project out on a different machine, it showed these files as "red" (makes sense, the newly checked out project is in a different location). I don't even know how a couple of files ended up in here. It just doesn't make any sense to use absolute paths at all.
To fix, I just modified this file to remove those lines, moved the files away into a tmp dir (since they were there), and added the missing files in Xcode.
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "group:/Users/jack/projects/myapp/myapp/MyController.swift">
</FileRef>
<FileRef
location = "group:/Users/jack/projects/myapp/myapp/CustomView.swift">
</FileRef>
...

Related

iOS My application.xcodeproj causes and display red text, Then I unable to open project?

I have facing this issue when I was changing project name and copying my project from one mac to another. There are some red texts indicate the missing files from the project source codes(But I have all files in Project folder) I have used cocoapods in this project. How to avoid these?
Here I have shown my project screen shot.
As per your description... you must be having some issue in your project.pbxproj file. Please check that file. Common issue happens in that file when you try to merge different branches having conflicts in project structure.
There could be different reasons of this:
It may happen because the xcode is open and the source folder is not available.
It may happen when source path is not found in your system and xcode shows that.
For resolving this, quiet xcode and reopen your source from .xcodeproj again, will resolve the problem.
Click on the file, then on the far top right of Xcode look under Identity and Type Check and see if the path to the file is correct. In my case is was not so I had to click on the small folder icon (not the arrow icon) and select the folder in finder.

Xcode 9 - Some folders marked with red text

In my project, there are some folders that have red text.
The project compiles and everything works, but I can't understand why only some folders have red text.
Check this.
It means they are not found on disk where your project believes they should be. Control-click and Show In Finder to see the folder location to locate the file and drag it back in to the project, and delete the bad reference.Missing. Maybe you moved them somewhere without deleting them from the project or something.
Edit: Don't delete it before add it first, and you should save backup from the files in another folder, also you have to use source controls like Bitbucket, GitHub, or GitLab.
The UI error feedback notifies you that the path is not found. You can select a new one using the folder icon in the right panel. In this way, all files in the folder keep the configuration so it is more convenient.
I illustrate it in the above screenshot.

Xcode 8 red files but not missing

I just saw a weird error on one of my iOS projects.
I'm using Xcode 8 (last release). I have some classes that I share along with other projects. This files are added to the project by reference, in case I need to edit them, I do it just once.
Everything works fine. But I saw that many of this files are on red in one of my projects. The weird thing is that everything works well. All libraries are included, everything runs perfectly. Like I said, the files are marked as red and I can not edit them directly from that project but they are not missing (paths are OK), I cannot go directly to the folder using "show on finder" option.
I tried replacing the folders. Also tried to added and copy them to the project folder. But nothing seems to be working.
I know, there are many threads about this issue but none of them worked for me because my files are not missing.
Did someone see this issue?
PS. I'm using git.
Select the file in the Project navigator on the left, then open the right side Utilities view and select the File inspector. Then click on the little folder icon and make sure that points to the right path.
I have the same problem - definitely not missing files. This is too late for OP but for anyone finding this ... it might help to change the file 'Location' setting from "Relative to Group" to Relative to Project" and then clicking on the folder to reselect the file. It worked for me. I think the path of the group can get messed up.
I would suspect that the files are missing, but Xcode is able to still compile because it's picking up older version from the derived data directories.
I would suggest clearing your derived data to be sure.
the files are marked as red and I can not edit them directly from that project but they are not missing (paths are OK), I cannot go directly to the folder using "show on finder" option
Then the paths are not OK. You need to find these files and add them to the project again. Then delete the red file references.

Error: no such file or directory

My project was working perfectly fine. I then moved some files around from the project's root directory to some subfolders. Now, when I try to run the app, I receive this error message:
<unknown>:0: error: no such file or directory:
'/Users/anapaix/Desktop/currencyExchange/CommentsController.swift'
And I receive this same error for all 20 of the files that I moved around.
Additionally, the files now show up in red like this in my project:
When I double click the file, an empty Swift file shows up, like there is nothing inside. I have a feeling there should be some easy fix to this, in order for Xcode to recognize these files, but just have no idea what it would be.
You moved the files. Xcode doesn't know that. You need to tell Xcode where the files are. (Note: the other answers work too, but if you don't want to remove them and add them again, you can use this method)
Select your red file(s), open the File Inspector (Option+Command+1), and click the folder (circled in red in the below screenshot). Then find your file(s) and click Choose. The filenames should go back to being black.
If multiple red files are in the same folder, you can select multiple files in the Project Navigator (left column, Command+1), click the folder icon in the File Inspector (still the one circled in red, but the text will be different; it might say "multiple selected" or something) and click the folder containing the files. Xcode should automatically detect all of them, provided the filenames haven't changed.
Go Xcode->File->Add Files... and add missing files to the project.
when you move any file in finder from the projewct workspace then xcode doesn't recognize the new path automatically, and xcode consider it as deleted. So,Please remove this files that are in red colour in your explorer.
Then again drag the files from the finder in to your project.
This way your project found the new file path of files for the compling.

Moving files around in XCode and IOS 7

I move some files into a subdirectory but now I get linking errors saying files can't be found. Where do I go (like a projects file) to tell XCODE where to look for the new files?
I tried removing everything and adding them back in but I still get missing files even though they are one directory in and added to the project.
Select a file in left panel, open inspector panel on the right and choose a path to file there.
Note: it's more efficient to do that if your files are organized into folders; that way, you only need to change the path to folder and the elements are relative to it.

Resources