10

The question has been asked several times for previous (old) versions of XCode, but answers don't seem to apply to XCode 16.

How to embed, in the Resources folder of an App Bundle, resources with structured folders ?

Whatever I do (e.g. Group or Folder (blue or grey) file structured in the Navigator), I still get a flat list of all resources, which of course can't work if you have several resources with the same name (but in different folders).

Example, this will not build with XCode 16 because of the 2 resources "Marguerite.jpeg": enter image description here

I even tried with an additional run script

cp -r $SRCROOT/MyResources $BUILT_PRODUCTS_DIR/$UNLOCALIZED_RESOURCES_FOLDER_PATH

but the Sandbox prevents that too.

3 Answers 3

25

The method is very obscure in XCode 16:

  1. Go to Copy Bundle Resources Phase
  2. Click the + Button
  3. Click Add Other
  4. Select the top directory of the structure you want to add
  5. In the "Choose options for adding these files" dialog, tick Create folder references
  6. Click Finish
Sign up to request clarification or add additional context in comments.

1 Comment

Thanks a lot ! So much better than my poor work-around.
2

You need to apply the build rules to the folder once instead of on each file it contains.

enter image description here

1 Comment

Do not name the folder "Resources", it causes a signing error.
0

Here is how I worked around the problem. Clearly not ideal, but working : I used scnassets to build the folder structure.

scnassets can be nested and are included in the Bundle as a tree of directories. The directory names are suffixed with the extension '.scnassets', but I can live with that.

enter image description here

If anybody has a better answer, I'll be glad to accept it.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.