xnth97/SymbolPicker

This is how to get the SF Symbols programatically

mackoj opened this issue · 0 comments

mackoj commented

Hi thanks for making your library,

If you want to programmatically obtain the list of symbols, here you go. It's not a complete example because I didn't handle the category, but they are in the bundle. I figure that it is feasible to get them.

They are located in this bundle: /Library/Developer/CoreSimulator/Volumes/iOS_21A328/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.0.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/SFSymbols.framework/CoreGlyphs.bundle/

More specifically, in this file: name_availability.plist.

// Read the content of CoreGlyphs
// /Library/Developer/CoreSimulator/Volumes/iOS_21A328/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS 17.0.simruntime/Contents/Resources/RuntimeRoot/System/Library/PrivateFrameworks/SFSymbols.framework

var symbols = [String]()
if let bundle = Bundle(identifier: "com.apple.CoreGlyphs"),
   let resourcePath = bundle.path(forResource: "name_availability", ofType: "plist"),
   let plist = NSDictionary(contentsOfFile: resourcePath),
   let plistSymbols = plist["symbols"] as? [String: String]
{
  symbols = Array(plistSymbols.keys)
}