Xcode 中意外删除的文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/30924740/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Accidentally deleted file in Xcode
提问by NickyNick321
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.
我不小心在 Xcode 的一个项目中选择了我的一个文件并推送了删除,它被删除了。有谁知道怎么恢复吗?它不会让我撤消。请帮忙。
回答by Tommy C.
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
文件本身不会被删除,它只是从项目导航器中删除。要重新添加它,请转到文件 -> 将文件添加到“projectName”并选择丢失的文件,如果需要,在导航到项目的文件夹后。或者直接按 cmd+z
回答by BrianAtkins
This file should be in the trash folder, look in that folder or you can search via apple spotlight.
该文件应该在垃圾文件夹中,在该文件夹中查找,或者您可以通过苹果聚光灯进行搜索。
回答by Najam
May be its too late but for someone else it might be good to know, that's why I am answering it.
可能为时已晚,但对其他人来说,知道这可能是件好事,这就是我要回答的原因。
- Go to File>>> Add Files'Your Project Name'there will be a list of all files which have been removed from project, selectand addthem back.
- Now these files are back in project, but they don't have any referenceyet 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 clickon that missing files and add that file to project.
- 转到文件>>>添加文件'您的项目名称'将列出已从项目中删除的所有文件,选择并重新添加它们。
- 现在这些文件又回到了项目中,但它们还没有任何参考,所以 xCode 会给你错误说“故事板没有这个名字的任何文件”,现在你必须添加参考,为此只需右键单击它丢失的文件并将该文件添加到 project。
NOTE: If you have removed files directly to trashthen restorefrom trash and repeat second stepto add referenceback in project.
注:如果您已删除的文件,直接到垃圾桶,然后恢复从垃圾和重复第二步添加引用项目回来。
回答by Dan Bray
The following steps will allow you to recover (a) deleted file(s):
以下步骤将允许您恢复 (a) 已删除的文件:
- Click on the trashicon on the bottom right
- Search for the file(s) and move it back into your project folder
- In XCode, go to File, Add Files to ..., then select the file(s) you've just restored
- 点击右下角的垃圾桶图标
- 搜索文件并将其移回您的项目文件夹
- 在XCode 中,转到File,Add Files to ...,然后选择您刚刚恢复的文件
回答by CommaToast
There are some files that XCode deletes utterly without warning. These files are permanently deleted unless you have a backup.
XCode 会在没有警告的情况下完全删除一些文件。除非您有备份,否则这些文件将被永久删除。
回答by Aashish
xCode8
代码8
if files appear to be red in colors..
如果文件看起来是红色的..
You may want to remove the file reference
, then add it again with a right click on a folder you want to add files to.
您可能想要remove the file reference
,然后通过右键单击要添加文件的文件夹再次添加它。
Use option,
Add Files to 'project'
, then add the removed files.
使用选项,
Add Files to 'project'
然后添加删除的文件。