Thomas Braun
Thomas Braun

Reputation: 1349

Way to easily show all SF Symbols icon in apps

I am working on an app that shows all the features available in SwiftUI. As part of it, I wanted to display all the SF Symbols that are available. I was wondering if there was a way to do it easily (without needing to type up all the names/variations).

Thanks

Upvotes: 10

Views: 6200

Answers (3)

Robin Phillips
Robin Phillips

Reputation: 1

The above answer doesn't work but it was helpful in pointing me towards a solution that does (at least for the Mac).

if let bundle = Bundle(identifier: "com.apple.CoreGlyphs"),
   let resourcePath = bundle.path(forResource: "symbol_search", ofType: "plist"),
   let plist = NSDictionary(contentsOfFile: resourcePath) {
    // use the plist to access the symbol where the key is the symbol string and value is a list of key words
}

Upvotes: 0

Eugene Dudnyk
Eugene Dudnyk

Reputation: 6030

Here is how it's possible. No warranty of any kind for this code on passing the App Store review process.

if let sfSymbolsBundle = Bundle(identifier: "com.apple.SFSymbolsFramework"),
    let bundlePath = sfSymbolsBundle.path(forResource: "CoreGlyphs", ofType: "bundle"),
    let bundle = Bundle(path: bundlePath),
    let resourcePath = bundle.path(forResource: "symbol_search", ofType: "plist"),
    let plist = NSDictionary(contentsOfFile: resourcePath) {

    /// keys in plist are names of all available symbols

}

Upvotes: 8

AlbertUI
AlbertUI

Reputation: 1517

You can copy them from SF Symbols app (cmd+A to select all, and cmd+shift+c to copy all the names, paste to a text file, and refactor the names to Image(systemName: "NAME") easily.

Upvotes: 14

Related Questions