'Files in Xcode not working (names in red)
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
Solution 1:[1]
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.
Solution 2:[2]
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.
Solution 3:[3]
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.
Solution 4:[4]
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.
Solution 5:[5]
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>
...
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Michele Giuseppe Fadda |
Solution 2 | Apar Parmar |
Solution 3 | Zvi |
Solution 4 | someUs3rAndUs3r |
Solution 5 | Jack |