A utility package for accessing SF Symbols and their categories.
Supports all SFSymbols versions through 4.1 (iOS 16.1, macOS 13.0, tvOS 16.1, watchOS 9.1).
Without SFSymbolsKit 😰
- Pass a string to the initializer, which is prone to error
- No compile time checks for errors
Image(systemName: "square.grid.2x2")
With SFSymbolsKit 🤩
- No typos
- Compile time check for availability
- Xcode can autocomplete
Image(sfSymbol: .squareGrid2X2)
Build your own version of the SF Symbols app using the included symbol categories and their symbols.
struct ContentView: View {
var body: some View {
NavigationView {
List(SFSymbolCategory.allCases) { category in
NavigationLink {
List(category.symbols) {
Image(sfSymbol: $0)
.help($0.rawValue)
}
} label: {
HStack {
Image(sfSymbol: category.icon)
Text(category.name)
}
}
}
}
}
}
Install using Swift Package Manager:
https://github.com/tweilu/SFSymbolsKit
enum SFSymbol: String, CaseIterable {
case ...
/// An array of alternate names and the raw value
var searchTerms: [String]
/// The unicode string value
var string: String?
}
Each symbol is marked @available
with the platforms that support it.
The default categories as displayed in the SF Symbols app are listed in SFSymbolCategory.allCases
as the following struct:
struct SFSymbolCategory {
let name: String
let icon: SFSymbol
let symbols: [SFSymbol]
}
Image(sfSymbol: .squareGrid2X2)
UIImage(sfSymbol: .squareGrid2X2)
NSImage(sfSymbol: .squareGrid2X2)
This package also includes the command line tool for generating the source files for SFSymbolsKit
. It uses a copy of the resources found in macOS at /System/Library/CoreServices/CoreGlyphs.bundle/Contents/Resources
.
SFSymbolsKit is released under the MIT License. See LICENSE for details.