Xcode - Automatically add all files in a folder to a target Xcode - Automatically add all files in a folder to a target xcode xcode

Xcode - Automatically add all files in a folder to a target


This is completely broken in Xcode. Adding folders by folder reference (@Pavel's answer) should be correct - but it just doesn't work. See also https://stackoverflow.com/a/42600782/2518722. I'm using Xcode 8.3 (update: still broken in Xcode 11), but it's been broken for many generations prior, too.

There isn't a perfect workaround, but this is what I do:

  1. Drag the directory into the project
  2. When asked, set options as follows:
    • Select Create groups for any added folder (ie, the opposite to what you think would be right)
    • Deselect Copy files if needed (because you want a link, not a copy).

Now any changes to files in the shared directory will be reflected in Xcode, which is good.

But, there's no way of refreshing the group. (Someone please tell me if I'm missing something obvious here.) So if you've added new files to the directory, you have to remove the group in Xcode and re-add it before those files show up. This is obviously inconvenient, but at least it's not too prone to user error - and is better than adding files manually one-by-one.

Have to say I find it pretty unbelievable that such a simple and necessary feature of a development environment is so broken here.


When you add files to Xcode project, you will have two options to choose from in files select dialog:

  1. Create groups for any added folders.
  2. Create folder references for any added folders.

You need to select the second option. In this case, Xcode will always reflect the changes to files and subfolders of selected folder.

It seems the question was asked a long time ago, but it's still on first place in google search, so hopefully it will be helpful for someone.


You can add multiple files to targets with this. But it requires some work in filtering what files you want.

Project > Target > Compile Sources > cmd+A to select all files > filter for .m files > click "Add"

Similar to other resources,

Project > Target > Copy Bundle Resources > filter for .png .wav .strings .xib .storyboard, etc. > click "Add"