Why can't I delete files from my XCode project?

10,353

Solution 1

That isn't how folder references work. The idea is that its only a reference, you can open files within it and save it from those editors, you can delete or move the entire reference throughout the xcode project, but you can't actually edit it - its read only as far as xcode is concerned. Likewise, you cannot restructure it (move internal files around).

I'm not to sure why apple decided to make this the case, but apparently they have.

If you want to know how one might use the xcode folder system, here's how I tend to use them with my projects:

Whenever I subdivide code into folders, when I drag them into my project I click "recursively create groups for any added folders". If you do this, you any changes you make within xcode will not reflect the actual file itself. As far as I know, there is no way to do this. What does happen then is that when you add a new code file to it, the directory starts off in that file by default. ie, you don't need to navigate to it manually when you create a new file.

I use folder references whenever I'm working with content for an application I'm using. This way, I add all my images, folders, configuration files, whatever - and xcode immediately lists them. The reason I have it within xcode, I can I copy the files into the executables directory by dragging the folder reference into a "Copy Files" build phase.

Thats basically (to my knowledge) how one uses the folder types within xcode - sadly, I don't know how to achieve the functionality you want. You may have to manually delete the folders in finder, which if you do use folder references will update xcode to the change.

Solution 2

I ran into the same issue by using "Create Folder References for any added folders". I wanted to change some of the times but that's not possible. I had added a main folder that had other directories under it. I just had to select the main directory and deleted it and then just add the subdirectories that I needed. You can't make any location or removal changes to the directories that are added this way. -- Jeff

Solution 3

I ran into the same issue. Delete the files from the folder directly as opposed to from within Xcode. You'll see the entries turn red under your project. Restarting Xcode should make these red entries vanish.

Solution 4

In the project browser, where you're looking at files, right click and choose "Delete". It'll prompt you to either remove the file from the project (leaving the underlying file on the filesystem) or to also move the underlying file to the trash.

Share:
10,353
jowie
Author by

jowie

Bedroom/pub/club DJ, biker, programmer, musician and general all-round great guy ;-)

Updated on June 04, 2022

Comments

  • jowie
    jowie over 1 year

    This is probably a very easy question, but I'm having trouble deleting resources from my XCode project. I added them using "Create Folder References for any added folders" so that I could import a whole offline HTML site with its correct folder structure.

    Unfortunately, now it has been added like this I don't seem to be able to delete individual files in the structure (it's not available from the Edit menu).

    Can anyone help please? Thanks!

  • Tomas
    Tomas almost 13 years
    I suppose I should note that you also need to run a small script to "Touch" the files you want copied so xcode knows to override the newer ones.
  • jowie
    jowie almost 13 years
    That's great, thanks. I assumed that the blue folder references were so that a group also equalled a folder. That is, if I wanted to import a whole bunch of files (such as an offline website), then their relative paths would still be the same. The idea of groups and referenced files in XCode is really tedious... I'd rather just have the files and folders as real files and folders inside my project! But then I'm more used to Eclipse :)
  • Tomas
    Tomas almost 13 years
    I agree, I really struggle to think of the advantages to having separate code grouping to filesystem grouping
  • Little Endian
    Little Endian over 10 years
    So if directory A has subdirectories B and C, and you want directories A and B in your project, you must also have C.