After a first build, Xcode complains the project is corrupted.

The files of the project are not lost. It is just the structure of the Xcode internals (including index for code-sense) that has been corrupted.

This is a known bug of Xcode. It occurs very rarely and the causes are unknown. Generally, it is raised by a race condition with another application, e.g. an anti-virus or other processes Xcode launches under-the-hood. 

  • Quit and relaunch Xcode.
  • Create a new project.
  • Launch a first Build to prepare the project.
  • Access the files of the initial project on the Finder.
  • Drag-and-drop the files of the initial project from the Finder onto the new project on Xcode.

If the above procedure doesn't solve the issue, 

  • Reboot the computer. 
  • Create a new project.