File cannot be copied to Project

I just started creating a test application, here's what happened.

  • I copied some files to my project.

  • deleted them only as a link.

  • I tried adding them again,

and I get the following error:

"randomfile.h could not be copied to TestApp because an element with the same name already exists"

randomfile.h is the file I'm trying to add, and TestApp is the name of the project.

How can I add the same file again?

+8
ios iphone xcode
source share
4 answers

Uncheck the box next to "Copy items to destination if necessary." Are you adding a file from the same folder? If it is from another folder, you need to rename or delete the one that you had before.

+28
source share

It worked, but I don’t understand why it happened, can you explain in detail?

You deleted the elements only by reference, this means that you deleted the link to it only in essence, removing it from the project, but not deleting it from disk. Thus, the file is still located on your hard drive in the project file directory. Trying to copy another instance will be similar to trying to copy 2 files with the same name to the same directory, so you get the message "because an item with the same name already exists"

+10
source share

However, this does not work if you delete folders. Here are the steps to play:

Add a folder called "images".

In this folder, add a folder called "test".

Put a couple of files in the test folder.

Delete the test folder. Select "move to trash" (instead of deleting links).

Try adding the β€œtest” folder to the image folder by dragging it from the finder.

An error message appears using OPP: xcode does not delete folders (or subfolders) when you select the move to trash option, even if this folder is selected. You need to manually delete folders from finder.

+2
source share

Go to the project directory to find and delete the file with the same name as the one you tried to copy to the project

+1
source share

All Articles