Yashwanth Kumar
Yashwanth Kumar

Reputation: 29121

File couldn't be copied to Project

I have just started making a test app , here is what happened.

  1. I copied some files in to my project.

  2. deleted them, as reference only.

  3. I tried to add them again,

and i get the following error

" randomfile.h couldn't be copied to TestApp because an item with same name already exists "

randomfile.h is the file i am trying to add and TestApp is the project name.

How can i add the same file again?

Upvotes: 8

Views: 9675

Answers (4)

Sean Chen
Sean Chen

Reputation: 117

Go to project directory to find and delete the file that has the same name as the one you were trying to copy to project

Upvotes: 1

Shaun Neal
Shaun Neal

Reputation: 1193

However, this doesn't work if you delete folders. Here are steps to reproduce:

Add a folder called "images".

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

Put a couple of files in the test folder.

Delete the test folder. Select "move to trash" (as opposed to delete references).

Try to add a "test" folder into the images folder by dragging in from finder.

Error by OP appears - xcode does not delete folders (or subfolders) when you select the move to trash option, even when you have that folder selected. You have to manually remove the folders from finder.

Upvotes: 2

ColdLogic
ColdLogic

Reputation: 7265

It worked, but i don't understand why this happened, can you explain in detail?

You deleted the items by reference only, that means that you only deleted the projects reference to it, essentially, removing it from the project, but not deleting it from disk. So the file is still on your hard drive in your project files directory. Trying to copy another instance of it will be like trying to copy 2 files with the same name into the same directory, thus you get the "because an item with same name already exists" error

Upvotes: 10

Matt H
Matt H

Reputation: 6532

Un-select the "Copy items into destination if needed" checkbox. Are you adding the file from and to the same folder? If it's from a different folder, then you need to rename or delete the one that you had before.

Upvotes: 28

Related Questions