I would like to use SF Symbols in my macOS project. How to implement one?
Button(action: {}) {
Image(systemName: "star") //Error: 'init(systemName:)' is unavailable in macOS
}
I would like to use SF Symbols in my macOS project. How to implement one?
Button(action: {}) {
Image(systemName: "star") //Error: 'init(systemName:)' is unavailable in macOS
}
It is nativly supporting from the 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 markdown of the StackOverflow
Remember that you should embed the font in your application or the destination should have the SF Symbols App installed
Apple's Human Interface Guidelines state:
You can use SF Symbols in apps running in iOS 13 and later, watchOS 6 and later, and tvOS 13 and later.
No Mac support at this time. ☹️
Before using this code you should install SF Symbols app
I makeImage
for macOS like below
that's how it looks on macOS