从Xcode项目中意外删除了xcassets文件 [英] Accidentally removed xcassets file from Xcode project

查看:240
本文介绍了从Xcode项目中意外删除了xcassets文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从图像集中删除一个文件夹,但是,我设法将整个xcassets文件扔进了垃圾桶.

I wanted to remove a single folder from the image collection, however, I somehow managed to throw the entire xcassets file into the trash.

无法使用常规的回退"方法,只需将已删除的文件夹拖动到Xcode就会产生错误:

The normal 'Put back' method is not available, and simply dragging the deleted folder to Xcode yields an error:

无法将"Images.xcassets"复制到"ProjectPear",因为已经存在一个具有相同名称的项目.
要保存文件,请提供其他名称,或移开或 删除现有文件,然后重试.

"Images.xcassets" couldn't be copied to "ProjectPear" because an item with the same name already exists.
To save the file, either provide a different name, or move aside or delete the existing file, and try again.

我不确定该集合在我的Xcode项目中的位置,因为导航器似乎未显示任何内容,并且命令行也未删除任何提示.我怕弄乱project.pbxproj文件,因为它可能不仅使我的图像收集更加混乱.

I'm not sure where this collection is located within my Xcode project, as the navigator doesn't appear to show anything, and the command-line isn't dropping any hints either. I'm afraid to mess around with the project.pbxproj file, as it might jumble up a lot more than just my image collection.

从废纸rash"将文件拖回Finder的操作已成功,但是Xcode导航器不再识别-.在这种情况下,仍然无法识别.xcassets文件.我不确定是否要在.pbxproj文件中添加一些内容.

Dragging the files back to Finder from Trash was successful, however, the Xcode navigator no longer recognises - or in this case, still doesn't recognise - the .xcassets file. I'm not sure whether to add something in the .pbxproj file.

推荐答案

我自己完成了此工作,并弄清楚了如何快速解决此问题.

I just did this myself and figured out how to quickly remedy the issue.

  1. 转到 Finder 中的项目文件夹.您应该发现 文件夹 Images.xcassets 仍然存在.

  1. Go to the project folder in the Finder. You should find that the folder Images.xcassets is still there.

将其移动到类似 Desktop 之类的单独位置.它 仍然拥有所有图像和json文件.

Move it to a separate location like to the Desktop or something. It still has all of the images and json files.

跳回Xcode并为图像创建新的资产目录.

Jump back to Xcode and create a new asset catalog for images.

File > New > File... > Resource > Asset Catalog

将其命名为图片.

退出Xcode并返回到Finder.

Quit Xcode and return to the Finder.

将文件夹从您的 Images.xcassets 内复制到 new 项目中的 Images.xcassets 目录.

Copy the folders from within your old Images.xcassets to the new Images.xcassets directory in your project.

启动Xcode,您就重新营业!

Launch Xcode and you're back in business!

这篇关于从Xcode项目中意外删除了xcassets文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆