Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do you duplicate a file in XCode?

Anyone know a good solution?

So far I have not found a better way than using File>New file and then copying contents from old file to new.

You can probably duplicate in Finder and re-import but that's almost same amount of work: switching to finder, duplicate, import new files.

Doing this with one class is not so hard, but what to do if you need to generate 10+ similar Classes based on superclass.

In Eclipse you select file and then copy/paste it in same folder. In finder there's Duplicate.

There's a menu Edit > Duplicate. But it's ALWAYS disabled. I tried selecting various files, classes, methods. It's still disabled.

like image 666
Rod Avatar asked Jul 07 '09 16:07

Rod


People also ask

How do you make a duplicate of a file?

Go to the location of the document you want to duplicate. Right-click the file, and click Open as copy. A new file opens and is named Copy of Document, Document 2, or similar. In the new file that opens, click the File tab, then click Save As.

Can you duplicate an Xcode project?

If you already have Xcode open, head to the Source control menu and click 'Clone'. If not and you are launching Xcode, you can clone a project by clicking on 'Clone' from the welcome screen.

How do I find duplicate files in Xcode?

Open "Project Navigator" (Menu View > Navigators > Project ⌘ - command + 1 ). Select Build Phases under your problem target. Open Compile Sources or Copy Bundle Resources section based on your warning. Find the problem files and delete one of them (You should see two files with the same name).


2 Answers

In XCode 4.2 (I know this is an old question) there is Duplicate under the File menu.

Select the file (you can select multiple files but it doesn't appear to do anything useful) in the Project Navigator and then File->Duplicate. Hooray!

like image 191
WiseOldDuck Avatar answered Oct 16 '22 20:10

WiseOldDuck


In Xcode 4.5 we can duplicate using File-> Duplicate or cmd + shift + S

like image 37
shinto Joseph Avatar answered Oct 16 '22 19:10

shinto Joseph