AirXygène
AirXygène

Reputation: 2959

How to build structured Resources folder in Bundle with XCode 16?

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.

Upvotes: 4

Views: 442

Answers (3)

Wojciech Nagrodzki
Wojciech Nagrodzki

Reputation: 2868

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

enter image description here

Upvotes: 0

macaroni n. cheese
macaroni n. cheese

Reputation: 96

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

Upvotes: 8

AirXygène
AirXygène

Reputation: 2959

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.

Upvotes: 0

Related Questions