Xcode 12 introduced support for using Scalable Vector Graphic (SVG) image assets in iOS, macOS, and iPadOS. It’s one of those changes that you might have missed during WWDC 2020 as it’s quite a small addition.

Up until Xcode 12, we were able to use single scale resources by using PDF assets. It takes away the need to generate individual images for each scale using the @1x, @2x, and @3x postfix. This saves you time and also takes away potential mistakes like accidentally generating a @3x asset with the @1x image size (we all did that once, right?).


What is a Scalable Vector Graphic asset?

Scalable Vector Graphics, also known as SVG, defines two-dimensional graphics defined in Extensible Markup Language (XML). It’s mostly used for icons and symbols and allows platforms to scale up the asset for the current active resolution.


When should I use Single Scale Assets?

SVG assets can not be seen as a replacement for all your assets. Rich assets like images with lots of details should still be defined as individual scales. If you have a logo, icons, or symbols, you can most likely look into replacing them with an SVG asset.


Supported platforms

It’s important to point out that SVGs are only supported on macOS 10.15 or later, iOS 13 or later, and iPadOS or later. If your app supports any older version you should not use single scale SVGs.


Considering SFSymbols as an Alternative

Before you start replacing all your assets with SVGs you might want to consider using SFSymbols instead. SFSymbols have the same platform version availability and are available as system images. This takes away some extra space in your app bundle.

#swift #programming #mobile #xcode #ios #svg

SVG Assets in Xcode for Single Scale Images
12.15 GEEK