Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

File couldn't be copied to Project

Tags:

xcode

ios

iphone

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?

like image 332
Yashwanth Kumar Avatar asked Nov 17 '11 19:11

Yashwanth Kumar


People also ask

How do you fix the file has properties that can't be copied to the new location?

First, copy any files off that USB drive, because this process will wipe the file from that drive. Then, in File Explorer, right click that drive and choose Format, then set NTFS as the file system and apply a Quick Format. That will take a small while to complete, then that drive will be converted.

What does it mean when properties Cannot be copied?

What does it mean when a file cannot be copied with its properties? Copying or moving a file without some of its properties from an NTFS drive to a FAT drive will simply mean that the properties will be lost, whereas the file will remain intact and functional.

How do I copy a server path?

Click the Start button and then click Computer, click to open the location of the desired file, hold down the Shift key and right-click the file. Copy As Path: Click this option to paste the full file path into a document.


4 Answers

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.

like image 94
Matt H Avatar answered Oct 20 '22 10:10

Matt H


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

like image 30
ColdLogic Avatar answered Oct 20 '22 10:10

ColdLogic


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.

like image 33
Shaun Neal Avatar answered Oct 20 '22 09:10

Shaun Neal


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

like image 28
Sean Chen Avatar answered Oct 20 '22 10:10

Sean Chen