Xcode Assets — Localization and Directions

Omar Labib
3 min readFeb 8, 2023

Learn about some of the cool gems about Assets in Xcode

Dealing with assets in Xcode is vital, I can’t think of a project that hasn’t used one. In this short article I will be explaining a few of assets amazing tricks.

1. Asset Localization

So we have this arrow asset that we use as back button here.

When loaded into an image view it’s displayed as follows.

However, when you change the app language into any RTL language, Arabic for example, you notice that the image has same orientation and thus can’t serve the purpose of back button.

Asset Localization comes to the rescue.

From attributes inspector at the right panel, you can localize the image for any language, Arabic for our case, and add a separate, flipped image for that language as follows.

Now we’ll have these variants..

Now the back arrow will be adjusted and displayed according to the language.

But that’s not all, there is a better way to do it 😉

2. Asset Directions

Now what if we support say 6 languages, 3 of which are LTR languages and the rest are RTL. Following the above approach leads to a lot of duplicated assets.

Asset direction comes to the rescue.

At the attributes inspector panel at the right, you will see this direction option with four available options.

This is exactly what will serve our purpose, let’s go over the options one by one.

Fixed: this will have the provided image set and fixed for both RTL and LTR directions.

Left to Right, Mirrors: this will set the provided image for the LTR direction and automatically mirror it for the RTL direction.

Right to Left, Mirrors: exactly the opposite to the above.

Both: this will gives you the possibility to provide two variants, one for each orientations, so we can provide two different assets as below.

However this won’t be language dependent, but rather it will be direction dependent, so it will solve the problem mentioned above without any assets duplication.

So Xcode seems to be very handy with dealign with assets, there are lots of options at the attributes inspector I encourage you to play with and explore.

Don’t forget to follow me for more. And also would love to connect on LinkedIn.

--

--