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

Viewed 3075

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.

3 Answers

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.

Related