Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Moving files within Xcode

Tags:

xcode

I want to move a file I have in PROJECT/PROJECT.xcodeproj to PROJECT/Classes.

The problem with just dragging within Xcode is that Xcode's file hierarchy system is different from the actual system.

The problem with moving it within Finder/Terminal is that it breaks things and things no longer work.

Please let me know of a solution. Thanks!

like image 548
SuperString Avatar asked May 25 '11 14:05

SuperString


People also ask

How do I group files in Xcode?

You can create a new group, with its own folder, directly in Xcode, but it's not at all obvious. Instead of choosing 'New Group', choose 'Add Files to “<Project>”'. Then, in the file picker dialog, click the New Folder button or press Command-Shift-N and type the name of the new folder/group.

How do I copy one project to another in Xcode?

Click the arrow button to the right of the file and select Move or Copy file from the dropdown menu. When you choose Copy this file from the move or copy dropdown, you will then be able to select which project to copy it to. You can make a copy of the file in the existing project or in another project.

How do I add files to a folder in Xcode?

Xcode offers several ways to add existing files and folders to your project: Drag the files from the Finder into the Project navigator. Click the Add button (+) in the Project navigator's filter bar, and choose Add Files to “projectName”. Choose File > Add Files to “projectName”.


2 Answers

Works in Xcode 5:

  1. Move the file in Finder
  2. Observe that the reference in Xcode turns red
  3. Open the right panel (⌘⌥0)
  4. Select “Relative to Project” from the Location picker.
  5. Click the folder icon under Location.
  6. Select the new file location.

This allows you to both move files and rename them (both at once if you like).

Edit: Notably, Xcode 9 supposedly will move files on the filesystem if your group structure mimics the file system.

like image 163
mxcl Avatar answered Oct 11 '22 12:10

mxcl


I have had the same issue. Groups do not represent folders in the file system. I solved my problem by

  1. removing the references from the project
  2. moving files into the right folders
  3. add files to the project again. (and do not check the "copy files" option)
like image 40
jules Avatar answered Oct 11 '22 10:10

jules