Xcode files in Red - but file still there - ios

I've been working on an Xcode project on my desktop, and I was trying to save it to GitHub, so I could access it on the road. I've saved it to GitHub before, without issues, and the local Desktop version was working fine. After saving it to GitHub, I tried downloading it on the laptop, to make sure everything was fine, and one file was in red. It doesn't look like it was saved or even exists. I get a "Build Input File can't be found" error.
I went back to the Desktop version - that file is there and everything works. I thought, maybe I messed up with GitHub, so I tried to save it to iCloud, and then emailed myself a zip copy - same thing. Every other version, but the desktop version, had that one missing file in red.
I've looked at other posts for those with similar problems, and all the answers seem to say the same thing - the file was moved or deleted; however, it is still there on my original desktop working version. Any thoughts as to what is going on or what I should do are welcome.
I'm working on XCode 13.1, on a Mac running iOS 12.1
Follow up - locked files:
As some of you suggested, the file could be locked. It didn't appear so, and I thought it unlikely, as I don't know how to lock them. I copied the one file over, added it, and it is running, however, I got this warning when I tried to save and close it:
Locked file warning
I went through the steps to unlock it, and curiously, finder says it is not unlocked. Not locked but I'm getting the warning
Everyone has permission too
Any ideas as to why this might be? I'm stumped. I did try locking and then unlocking it, but no dice. I still get the error I don't have permission because it is a locked file.

Probably the file is not inside the project folder. This can easily happen with resources such as images and sound files that you copy to the project navigator. The project works fine but it has an external reference to the file. If the project folder is copied, eg zipped, the file is missing because it was not part of what was copied.

This generally occurs when you moved or deleted that file within Finder.
So try to delete that file from your project in Xcode and then re-add that file to your project folder in Xcode. Then your file would be working fine.

first: get your file from the current full path and cony it to any location on your mac enter image description here
Second: delete the red file from Xcode
third: drag file from the new location to Xcode don't forget to check on copy if you needed :)

Related

The document “ViewController.swift” could not be saved. The file doesn’t exist

When I move ViewController.swift file another group X-code show popup and I click re-save. after all when I try to close my project Xcode show this message The document “ViewController.swift” could not be saved. The file doesn’t exist.
This happens quite often when moving files around.
What I do:
Locate the file in your project folder and drag to desktop
In xcode delete the file
Close Xcode, you may have to force quit if it keeps showing the The document “ViewController.swift” could not be saved. The file doesn’t exist. alert.
Reopen xcode and drag the file from your desktop to the folder in
xcode project where you want it to be.
Build and the message should have gone.
Make a zip of that project and delete the original project. After that force quit the system. Then start the system again and unzip the zipped project.
Thank-You
This issue occurred to me when I tried to move an xib file to a group.
I reverted my work and still the error occurred although the project was running normally.
I switched to a different git branch and ran my code it ran normally with no error message, then I returned to my branch again and ran the project and the error message disappeared.

deleted xcode file not opening

I accidentally deleted my xCode project and when I tried to open it back up I was getting this weird message. I am new to xCode and should have used version control first thing. I think it might have something to do with a .app instead of .xcodeproj file type but why would in turn into this in the first place?
https://i.stack.imgur.com/FzxwNm.png
I would have used these images but my reputation is not high enough.

After changing file locations, project can't recognize some of my classes

First off, I know this is a config issue because my code was building and running just fine before I synced my project to GitHub. Xcode's internal source control seems to be having trouble recognizing some of my files and I'm getting Use of unresolved identifier... errors where these files' initializers are in use, and were working before. I'm running the latest versions of Xcode and OS X, and these are the steps I was taking before and after the issue started...
BEFORE:
After several rounds of implementation and committing with the default local repository, I built and ran the app multiple times with no issues.
I created a new repository on GitHub, committed (w/push to remotes) and everything made it to GitHub just fine and was building and running in the simulator.
In order to organize the repository (to match the 'groups' I had created in Xcode) I did some brief research and then added nested directories to my project folder. I re-opened Xcode and repaired the file paths. Some took, but several kept showing ? (although I could still access the code just fine) and I got the corresponding Missing Files... warnings.
Because I couldn't get the new hierarchy to work (the files w/?s, not being recognized, were not able to be committed to GitHub), I tried to move the files back. This worked for most, but for a few (which seem to be the effected files) I had to rename them, recreate a new file and then paste their contents over (this is where I think the problem lies). I was able to commit everything to GitHub (even the problem files went up) but all the warnings remained.
To clear out the warnings I attempted to run my tests, and that's when the Use of unresolved identifier... errors popped up, and of course the build failed.
AFTER:
I verified all the paths and target memberships were correct.
When that didn't work, I built an entirely new project (although I did add it to the same workspace; not sure if that matters) and copy/pasted all my code over to new files. I didn't drag / reference the files and I didn't link the new project to GitHub. When I went to build, same errors in the same places...
I exited the workspace and opened the new project separately. Still no joy.
Any help or points in the right direction would be much appreciated.
EDIT:
After some help, I tried deleting the reference and dragging the file in manually but that didn't resolve the issue.
I also checked Build Phases -> Compile Sources and everything was listed fine with no compiler flags. I removed and re-added from Compile Sources, issue persists.
You can try removing referencer for the missing class file in Xcode,then add same file to folder (right click add file ) from physical workspace location this might help.
After rebuilding an entirely new app a third time, with all new files, I copied the files over and this time everything seems to be working fine. Had to repair a bunch of provisioning issues to make sure it worked (maybe that was part of the problem, but I doubt it), but everything is back to normal with the app. The only thing I did differently this time was not adding the new project to the same workspace.

Get lost Xcode binary from archive in organizer?

Alright, so I had been having issues with this and never resolved them, finished my app and published it before this caused major problems -
I have pods installed for my Xcode project so I had been working off a workspace. I had always backed up in the past by copy pasting my project folder then renaming, however more recently something happened that cause every change to my workspace to affect all previous versions.
I tried everything - saving to external hard drive, github, etc but I just ended up going on working on the workspace and making sure I didn't screw anything up. Along with this issue whenever I clicked on the Xcode project that is in the project folder, none of my new code would be there.
That Xcode project version was from several months back and the only way to see my new code was to click on the workspace. I asked a question about this but no one had an answer.
A week ago I finished the app, archived and uploaded to App store. It is now published, however I want to update so today I went to my workspace and the project file above the pods file was RED meaning not there.
I have no idea why this would have happened. Dragging the Xcode project i the folder to the workspace again, just runs the very old version.
I need to get my binary back and solve this problem. Im desperate. I have this:
One of the export options is save for development and such.. Is there a way to get my binary back from this archive? How can I fix this problem?

Xcode weird random error that doesn't go away

I have a regular project i'm working on for a while -
I've edited the plist file, which caused some problem, so i've reverted to the old plist file (where all used to work), but the following errors always show and dont go away,
I've tried cleaning the project (Cmd+Shift+k , Cmd+Opt+Shift+k) , Tried resetting my pbjprox, tried clearing ~/Library/Developer/Xcode/DerivedData/ and /var/folders
Nothing works, and i guess the errors are cached somewhere that i can't think of...
Would appreciate your hints about this
Shai
This is easy to fix - your files are not on location where Xcode expects them. Just delete the file from your project and add it again.
If this doesn't work, it can be a collision with your versioning system - see Missing file warnings showing up after upgrade to XCode 4
I would copy these files into another location (outside the project folder) and then remove them from the project and add them back (Add Files to ...). Make sure to select Copy Items into destinations group's folder
Sounds like Xcode is a little confused about the association of these files to your project.

Resources