When I tried to reset a file to default, the file name turned red and It seemed to be an error file. I try to delete and cread another file with same name but didn’t work. Can anyone help me please?
Can you provide a screenshot of what you mean by the filename turning red?
Your project is under version control. The letters M and A next to the files in your screenshot indicate that your project is under version control.
When you add a new file to a project under version control, the file has an A next to it, like the style file in your screenshot. A file with an A next to it is ready to add to the repository the next time you commit. When you discard changes to a file with an A next to it, you are discarding the adding of the file. You are telling git to not add the file to the repository. You are essentially deleting the file. That’s why the file is in red. It no longer exists.
To avoid this problem in the future, commit new files when you add them to your project.
I’m not sure why you can’t delete the file in red (data in your screenshot). I just tested on my machine, and I could delete the red file by selecting it and pressing the Delete key.
The most common cause of a file showing up as RED is when you delete the file from within Finder rather than within Xcode. The LearningSwiftApp.xcodeproj file keeps track of the structure of your Xcode project so when you add or delete files from the project you should do so in the FileNavigator panel on the left rather than in Finder.
To solve the problem, place your cursor on the
data file and hit the delete key then drag in the version of
data.json that you want to use.