Xcode 11, Asset catalogue naming convention for dark / light images?
Asked Answered
M

1

7

Previously images dragged into the Xcode asset catalogue could be named as follows ...

[email protected]
[email protected] 

on releasing the drag these images were automatically assigned to the correct 2x & 3x slots within the catalogue.

Now with iOS 13 and Xcode 11 we have the ability to add an alternate set of images for use in dark mode. Does anyone know of if there is a way to specify light / dark as part of the filename so that images automatically end up the light and dark slots.

i.e.

[email protected]
[email protected]
[email protected]
[email protected] 
Merchantman answered 4/10, 2019 at 15:6 Comment(0)
D
7

Previously images dragged into the Xcode asset catalogue could be named as follows

Yes, that's because those names were used, years ago, before there were asset catalogs, when the image files had to live in the app bundle itself. There had to be a way to let the runtime know how the image was to be used, and those naming conventions were the only way. Nowadays, though, that's not needed; the images can have any names, because they just go into slots of an Image Set. But Apple provides a shortcut so that you can easily switch from using the app bundle to using the asset catalog, thus coming into the modern world.

with iOS 13 and Xcode 11 we have the ability to add an alternate set of images for use in dark mode. Does anyone know of if there is a way to specify light / dark as part of the filename so that images automatically end up the light and dark slots

Yes, there is no such way. Apple long ago stopped adding naming conventions for further distinctions among image files in the app bundle itself, because now the asset catalog exists and it has slots. So obviously there is no app bundle naming convention for light/dark mode, which just started existing. There is no need for a shortcut because you were never using a naming convention to begin with. You don't need to come into the modern world because you're already in it. Just put the images in their slots. You can automate that process, but mere naming conventions is not the way.

Drapery answered 4/10, 2019 at 15:21 Comment(4)
Ah I see, yup I get it now, previously I was just dragging images in, but having revisited it after your comments I notice that you can create a "New Image Set" with a name to reference in code, then it matters not, what you call images that you drag into the slots. Perfect, much appreciated Sir.Merchantman
Such a shame! I liked that naming conventions. Sketch and other software are using that convention to provide a faster asset adding experience. Now we have to drag and drop one by one for dark appearanceDonal
@SepehrBehroozi File an enhancement request with Apple.Drapery
Actually they have one, but not exactly for asset catalogues: developer.apple.com/documentation/docc/… e.g. [email protected]Tymon

© 2022 - 2024 — McMap. All rights reserved.