开发者

Trying to add files, get error message: The operation couldn't be completed. File exists

开发者 https://www.devze.com 2023-04-01 03:46 出处:网络
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:

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: 开发者_如何学Python

Trying to add files, get error message: The operation couldn't be completed. File exists

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.


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


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.


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.


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.


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


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!


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.


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.


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号