65

I'm trying to add some new resource files to a project which was build by another person on another mac. I think that the project has the provision of the previous person.

Using right click->Add Files to "MyProject" doesn't provide the expected result. After I compile the project, the added file is not visible in the application.

How can I add new resources in my project?

PS: I'm trying to learn Objective-C in a macincloud.com account.

Mo Abdul-Hameed
  • 6,030
  • 2
  • 23
  • 36
dole doug
  • 34,070
  • 20
  • 68
  • 87
  • When you say "After I compile the project, the add file is not visible in the application," what do you mean? Is it not where you expect, but is someplace else in the resulting bundle, or is it not anywhere in the bundle? Is it in a Copy Resources phase anywhere? What sort of resource file is it? An image? A sound? Please give more information. – user1118321 Apr 22 '12 at 16:28
  • @dole-doug did you get your question answers? If so, accept the answer given or elaborate your question. – Paul Peelen May 08 '12 at 11:27

4 Answers4

79

It might be that the file you added was not added to the project build. Click your project > App target > Build Phases And check that the file exists in Compile sources (if it needs to be compiled), otherwise check Copy bundle resources. If the file does not exist there, drag it there and it should be fine, (from what I understand of your question).

EDIT

You can also check wether a file is added to the target by clicking the file and opening the "File Inspector" (View > Utilities > Show File Inspector, or + + 1), and check the Target Membership section.

Example:
Example

Paul Peelen
  • 10,073
  • 15
  • 85
  • 168
  • 1
    If you check these and it still fails, it may be that an xcode update moved the destination folder (this happened to me). So instead of being in `myapp.app/sounds` they are in the root `myapp.app/` location. – SimplGy Nov 15 '16 at 00:38
  • 1
    Solution for subfolder issue: http://stackoverflow.com/questions/10969555/resource-files-in-subdirectory-are-copied-to-root-directory-of-the-app-bundle – SimplGy Nov 15 '16 at 00:53
19

Adding to Copy bundle resources worked for me

enter image description here

nanospeck
  • 3,388
  • 3
  • 36
  • 45
  • 1
    "Copy Bundle Resources" does not exist in recent versions of Xcode. – Andrew Koster May 05 '20 at 23:22
  • 4
    @AndrewKoster I see it in Xcode 11.5. If you don't see that phase, click the plus icon near the upper left of the frame, then select "New Copy Bundle Resources Phase" – kevlened Jun 20 '20 at 16:11
15

Just drag the resource file (from a finder window) into your project files area (left side) and drop in supporting files.

Once you drop, a dialog will prompt you which targets to add it for. Select all that are appropriate. Thats it.

vpathak
  • 1,133
  • 12
  • 12
2

Just had a similar experience with Xcode Version 11.7 (11E801a), which I mention as it may help others from wasting a day and a half.

In addition to the other answers explaining how to add the resources:

For me the problem was I had my resources listed in Developer Assets under the target's General tab, but also in the Build Phases/Copy Bundle Resources. This worked fine running through Xcode in simulators and even on devices, but when I came to Archive the app, the resources were not being copied. Deleting my resources from the Developer Assets list, but keeping them in Build Phases worked.

And in the end it turns out I only need the resources in the Build Phases section for either running through XCode or Archiving !