Search code examples
iosxcodeassets

Does putting images in folder references still allow @2x and @3x optimizations?


In Xcode asset catalogs, each image asset has slots for normal size, @2x, and @3x images that Xcode uses to bundle the proper asset for a given device resolution.

Do you get that same benefit if you put @2x and @3x assets into a folder reference in the app bundle? (In Xcode UI, these show up as blue folders, but the @2x and @3x images show up as separate images.)

enter image description here
Folder Reference in Xcode Containing @2x and @3x Images


Solution

  • No, you don’t get the same benefits. You should use asset catalogs.

    See QA1795, which mentions:

    Asset Catalogs help maximize the size reduction provided by App Slicing, which can be significant for apps with assets not needed by every device.

    If you want a folder structure, you could put a separate asset catalog in each folder.

    There are other benefits of asset catalogs as well, like image slicing, on-demand resource tags, and customizable compression options.

    Worth watching the app thinning WWDC talk as well.