1

I have installed SF Symbols 2, I would like to use its icons without having to copy the symbol.

Is there any way to use it on macOS?

From what I understand it only works on iOS.

I tried to export icon as svg, but the whole example is exported, so the whole set of that icon.

Version:

macOS: 10.15.4
Xcode: 11.7
Mojtaba Hosseini
  • 95,414
  • 31
  • 268
  • 278
Paul
  • 3,644
  • 9
  • 47
  • 113

1 Answers1

2

If you wish to use sf symbols in the macOS, (including the colored version) You need to install macOS 11 beta or later, then it works as usual, otherwise you have to export a template and import it to the assets catalog, then you can use it as a normal image. So:

if #available(OSX 11.0, *) {
    Image(systemName: "trash.fill")
} else {
    Image("trash.fill") // Imported as a supporting format like PDF (not SVG)
}

Another way is to use the symbol directly in the text:

Text("") // The symbol itself can not be shown on the mark down of the StackOverflow

Demo

Remember that you should embed the font in your application or the destination should have the SF Symbols App installed

Mojtaba Hosseini
  • 95,414
  • 31
  • 268
  • 278
  • 'init(systemName:)' is unavailable in macOS – Paul Sep 03 '20 at 14:51
  • So the only way is to export the image from sf as svg? I tried but it exports the whole set of that image, as I previously indicated in the post. – Paul Sep 03 '20 at 15:32
  • You need a third-party application like Sketch to convert each symbol to an image or you can use an SVG framework. – Mojtaba Hosseini Sep 03 '20 at 15:34