Adding resource files to xcode
Solution 1:
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:
Solution 2:
Adding to Copy bundle resources
worked for me
Solution 3:
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.
Solution 4:
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 !