NickyNick321
NickyNick321

Reputation: 223

Accidentally deleted file in Xcode

I accidentally had one of my files selected in a project in Xcode and pushed delete and it was deleted. Anyone know how to recover it? It won't let me undo. Please help.

Upvotes: 10

Views: 27817

Answers (5)

CommaToast
CommaToast

Reputation: 12178

There are some files that XCode deletes utterly without warning. These files are permanently deleted unless you have a backup.

Upvotes: 0

Dan Bray
Dan Bray

Reputation: 7822

The following steps will allow you to recover (a) deleted file(s):

  1. Click on the trash icon on the bottom right
  2. Search for the file(s) and move it back into your project folder
  3. In XCode, go to File, Add Files to ..., then select the file(s) you've just restored

Upvotes: 4

Tommy C.
Tommy C.

Reputation: 139

The file itself is not deleted, it is simply removed from the Project Navigator. To add it back, go to File -> Add files to "projectName" and select the missing file, after having navigated to the project's folder if needed. Or simply hit cmd+z

Upvotes: 10

Najam
Najam

Reputation: 1159

May be its too late but for someone else it might be good to know, that's why I am answering it.

  1. Go to File >>> Add Files'Your Project Name' there will be a list of all files which have been removed from project, select and add them back.
  2. Now these files are back in project, but they don't have any reference yet so xCode will give you error saying "Storyboard do not have any file of this name", now you have to add references, for this just right click on that missing files and add that file to project.

NOTE: If you have removed files directly to trash then restore from trash and repeat second step to add reference back in project.

Upvotes: 8

BrianAtkins
BrianAtkins

Reputation: 1349

This file should be in the trash folder, look in that folder or you can search via apple spotlight.

Upvotes: 6

Related Questions