wikipediabrown/sfsymbolskit
SFSymbolsKit is a tiny ***Swift*** package that provides extensions to `String`, `UIImage` and `NSImage` to make using **SFSymbols** easy peasy. The extensions and the accompanying `Enum` are all generated using the python scripts included in this package along with a list of all
π οΈ Installation
SFSymbolsKit can be installed with Swift Package Manager.
Swift Package Manager (Xcode 15.3 or higher)
The preferred way of installing SFSymbolsKit is via the Swift Package Manager.
- In Xcode, open your project and navigate to File β Swift Packages β Add Package Dependency...
- Paste the repository URL (
https://github.com/WikipediaBrown/SFSymbolsKit.git) and click Next. - For Rules, select Version (Up to Next Major) and click Next.
- Click Finish.
π©π½βπ» Usage
π§΅ String
You can use the String extension to get the name of all of the SFSymbols available. You can add an image like this:
Image(systemName: String.SFSymbols.plusApp)
.resizable()
.scaledToFit()
.aspectRatio(contentMode: .fit)
.foregroundColor(.primary)π©» UIImage
You can use the UIImage extension to get the image of all of the SFSymbols available. You can add an image like this:
Image(uiImage: UIImage.SFSymbols.plusApp)
.resizable()
.scaledToFit()
.aspectRatio(contentMode: .fit)
.foregroundColor(.primary)πΎ NSImage
Uou can use the NSImage estnsion to get the image of all of the SFSymbols available. You can add an image like this:
Image(nsImage: NSImage.SFSymbols.plusApp)
.resizable()
.scaledToFit()
.aspectRatio(contentMode: .fit)
.foregroundColor(.primary)π Enum
Additionally, there is an enum that is CaseIterable that provides access to all of the strings in the String extension and access to all of the images through an image property.
Image(uiImage: SFSymbol.plusApp.image)
.resizable()
.scaledToFit()
.aspectRatio(contentMode: .fit)
.foregroundColor(.primary)or
Image(nsImage: SFSymbol.plusApp.image)
.resizable()
.scaledToFit()
.aspectRatio(contentMode: .fit)
.foregroundColor(.primary)or
Image(systemName: SFSymbol.plusApp.string)
.resizable()
.scaledToFit()
.aspectRatio(contentMode: .fit)
.foregroundColor(.primary)𧬠Generation
The scripts used to generate the extensions and enum are written in Python 2.7.18. Which means you'll need Python.
π Get Python
Assuming you're running macOS, you should first install Homebrew and then use Homebrew to install Python by running the command brew install python.
π Get List of Names
Get list of names of SFSymbols by opening the SFSymbols App (you can get it from ο£Ώ Developer) and paste it into the SFSymbols.txt file. Check out this StackOverflow post.
ππ½ββοΈ Run Python Scripts
Run the command bash generateSymbols.sh. This command runs a bash script that in turn runs the command brew install python and then the command python3 UIImageExtension.py && python3 UIImageExtensionTests.py && python3 StringExtension.py && python3 StringExtensionTests.py && python3 Enum.py. This runs the python scripts will regenerate the String and UIImage extensions and enum.
π§ͺ Test
Run command+u in Xcode to run the unit tests. Test are run automatically for all pull requests. When running tests locally, be sure to be using iOS 17.2 or later or macOS 14.5 or later. Some symbols are not included in earlier versions. Releases of SFSymbolsKit support SFSymbols 5.1.
ποΈ Fastlane Scan
You can also run tests on both iOS & macOS using fastlane. This requires installing fastlane which in turn requires installing Homebrew. With Homebrew and fastlane installed you can open a terminal and navigate to the SFSymbolsKit's root folder and run the command fastlane unit_test. This will run the unit tests for both iOS & macOS in succession. You should expect to see 100% code coverage for both test runs.
π Versioning
SFSymbolsKit releases a new version on GitHub automatically when a pull request is approved from the develop branch to the master branch.
π©π½βπ» Contribute
Send a pull request my dude... or create an issue.
πͺͺ Licence
SFSymbolsKit is available under the MIT license. See the LICENSE file for more info.
<p align="center">Made with π²π²π² in Cascadia</p>
Package Metadata
Repository: wikipediabrown/sfsymbolskit
Default branch: master
README: README.md