尝试添加文件时,收到错误消息:操作无法完成。文件存在

发布于 2024-12-02 16:22:24 字数 176 浏览 1 评论 0原文

我需要替换我的应用程序中的一些图像。结果我从 Xcode 中删除了它们,现在当我尝试再次添加它们时,我收到此错误: 在此处输入图像描述

我确信该文件在项目中不存在,因为我刚刚删除了它。另外,当我尝试查找该文件时,它不存在。

I need to replace some images in my application. As a result I deleted them from Xcode and now when I try to add them again I get this error:
enter image description here

and I am sure that that file does not exist in the project because I just deleted it. Also when I try to look for that file it does not exist.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(9

坐在坟头思考人生 2024-12-09 16:22:24

试试这个:

  1. 转到旧图像所在的文件夹并将其再次放在那里。
  2. 转到 xcode 并单击“将文件添加到 xcode”,再次选择旧图像并添加它。
  3. 从 xcode 中删除其参考和物理图像。
  4. 添加新图像(您可以拖放到 xcode 或使用将文件添加到 xcode)

希望这有帮助

Try this:

  1. go to the folder were the old image was and place it there again.
  2. go to xcode and click on add files to xcode, select the old image again and add it.
  3. remove the image form xcode both its reference and physically.
  4. add the new image (you can drag and drop to xcode or use add files to xcode)

Hope this helps

非要怀念 2024-12-09 16:22:24

它与我不久前提交的 Xcode bug 有关:

2011 年 3 月 15 日 06:26 Johannes Fahrenkrug:摘要:当我尝试复制时
通过拖放一堆文件到我的 Xcode 项目,选中“复制
到项目”复选框和我想要复制的文件之一
存在,Xcode 会因错误而停止。到目前为止,一切都很好。但当我尝试
再次复制(没有已经存在的文件),我得到一个“多个
复制文件时发生错误”消息。事实证明,
Xcode 复制了一些文件并将它们留在磁盘上,但是
还没有将它们添加到项目中。所以我必须手动删除它们
从磁盘中重新拖放它们。

重现步骤:通过拖放将 3 个文件复制到您的项目中。
其中一个文件必须具有已存在的文件名。等待
错误,那么只需复制项目中不存在的2个文件
还没有。

预期结果:它应该复制文件。

实际结果:我因错误而崩溃。

回归:

注释:文件名也可能很重要:如果已经存在
文件以“a”开头,其他文​​件以“z”开头,可能没问题
因为它会在第一个文件上崩溃并且不会复制任何内容。

It's related to an Xcode bug I filed a while ago:

15-Mar-2011 06:26 PM Johannes Fahrenkrug: Summary: When I try to copy
a bunch of files via drag and drop to my Xcode project, check the "copy
to project" checkbox and one of the files that I want to copy already
exists, Xcode stops with an error. So far, so good. But when I try to
copy again (without the file that already existed), I get an "Multiple
errors occurred while copying the files" message. It turns out, that
Xcode had copied some of the files and had left them on the disk but
had not added them to the project. So I have to manually delete them
from disk and the drag and drop them again.

Steps to Reproduce: Copy 3 files to your project via drag and drop.
One of the files has to have a filename that already exsits. Wait for
the error, then just copy the 2 files that don't exist in the project
yet.

Expected Results: It should copy the files.

Actual Results: I craps out with an error.

Regression:

Notes: The file names might be important too: If the already exsiting
file starts with an "a" and the others with a "z", it might be OK
because it craps out on the first file and doesn't copy anything.

青芜 2024-12-09 16:22:24

在第一个错误之前复制的文件仍然存在,只是尚未添加到目标中。您需要使他们成为目标成员。 xCode 3.x 中的行为也是相同的。因此,完成此操作后,只需将剩余的文件拖到项目中即可。

the files that were copied prior to the first error are there, they just have not been added to the target. You need to make them members of the target. It was the same behaviour in xCode 3.x. So after you do that, just drag the remaining files into the project.

爱已欠费 2024-12-09 16:22:24

就我而言,有一个现有文件不知何故不想被覆盖。在终端上,执行 a

git rm -f <old_problematic_file>

然后尝试再次将文件添加到 Xcode。

In my case, there was an existing file that somehow doesn't want to be overwritten. On the terminal, do a

git rm -f <old_problematic_file>

Then try adding the file again to Xcode.

半世晨晓 2024-12-09 16:22:24

我通过进入项目的文件夹并删除旧文件然后再次添加它们来纠正错误

I corrected the error by entering the project's folder and deleting the old files and then added them again

傲世九天 2024-12-09 16:22:24

我在删除 xcode 内文件夹的内容然后将与文件夹先前内容同名的文件添加到项目后遇到了这个问题。

删除 xcode 中现在为空的文件夹后,问题消失了......

希望它可以帮助别人!

I got this problem ater deleting the contents of a folder inside xcode and then adding files with the same name as the folders previous content to the project.

After deleting the now empty folder inside xcode the problem disappeared...

Hope it helps someone!

も让我眼熟你 2024-12-09 16:22:24

添加额外图像时遇到同样的问题,因此检查了 Finder 中的实际文件夹位置,发现有所有文件,但 Xcode“资源管理器”中没有。因此,只需右键单击“资源管理器”中顶部的项目图标并选择“添加文件”...这一次,它确实导入了所有内容,虽然导入到了项目的根目录,但只是将图像拖到了 Images 文件夹中并删除了 2先前已识别的文件的重复项。它询问是否删除引用或移至垃圾桶,我选择了前者。执行“清理”、“构建”、“运行”。现在可以正确运行了。

Had the same problem adding extra images, so checked the actual folder location in Finder and there were all the files, but not in the Xcode "explorer". So just right-clicked on the top project icon in the "explorer" and selected Add Files... This time, it did import everything, although to the root of the project, but just dragged the images to the Images folder and deleted 2 duplicates of files that were already recognized previously. It asked whether to remove references or move to trashcan and I selected the former. Did a Clean, then Build, then Run. Now it runs correctly.

稚然 2024-12-09 16:22:24

我遇到了同样的错误,并且能够解决它:

当我删除(“移动到垃圾箱”按钮)xcode 中的原始文件时,这些文件以某种方式被移动到另一个文件夹而不是被删除。因此,在 Xcode 中删除(“移至垃圾箱”)文件后,它们仍然存在。在查找器中,我查看了我的项目文件夹,终于在新文件夹中找到了文件。从 Finder 中的新文件夹中删除文件后,我可以在 Xcode 中再次添加这些文件。

I got the same error and I was able to solve it:

When I deleted ("move to trash"-button) the original files in xcode, the files somehow were moved to another folder instead of being deleted. So, after deleting ("move to trash") the files in Xcode, they were still there. In finder, I looked at my project folder and finally found the files in the new folder. After I deleted the files from the new folder in finder, I was able to add the files again in Xcode.

冬天旳寂寞 2024-12-09 16:22:24

如果您收到此错误并且已经从 Xcode 中的项目中删除了文件。
1.导航到项目存储在其目录中的位置,然后从最初存储在项目文件夹中的位置删除图像,可以是 images 文件夹或 images-xassets 文件夹。然后删除图像或图像。
2.返回你的Xcode--Product-Clean..然后Build,
3.然后再次尝试添加您的图像。

If you you are getting this error and already deleted the files from your project in Xcode.
1.Navigate to where the project is stored inside its directory and delete the image from wherever you initially stored it inside your project folder,it can be the images folder or images-xassets folder..then delete the images or image.
2.Return to your Xcode--Product-Clean..then Build,
3.then try adding your image again.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文