Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mnkgitbox/appsymbol
SFSymbol is only available above the iOS 13, So we have to check the iOS version every time when we using the SFSymbol below iOS 13 deployment target projects. We can get rid of this boilerplate code using the AppSymbol framework.
https://github.com/mnkgitbox/appsymbol
programatically sfsymbol sfsymbol2 sfsymbols swift swift-3 swift-library swift4 swift5
Last synced: about 1 month ago
JSON representation
SFSymbol is only available above the iOS 13, So we have to check the iOS version every time when we using the SFSymbol below iOS 13 deployment target projects. We can get rid of this boilerplate code using the AppSymbol framework.
- Host: GitHub
- URL: https://github.com/mnkgitbox/appsymbol
- Owner: MnkGitBox
- License: mit
- Created: 2022-01-17T07:06:10.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2022-01-23T10:07:09.000Z (about 3 years ago)
- Last Synced: 2024-12-20T12:39:06.377Z (2 months ago)
- Topics: programatically, sfsymbol, sfsymbol2, sfsymbols, swift, swift-3, swift-library, swift4, swift5
- Language: Swift
- Homepage:
- Size: 499 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README

[](https://cocoapods.org/pods/AppSymbol)
[](https://cocoapods.org/pods/AppSymbol)
[](https://cocoapods.org/pods/AppSymbol)
Use the *SFSymbol* in your ios 13 below deployment target projects without any version check.
## Why App Symbol?
SFSymbol is only available above the iOS 13, So we have to check the iOS version every time when we using the SFSymbol below iOS 13 deployment target projects. We can get rid of this boilerplate code using the AppSymbol framework.
## Installation
### CocoaPods
[CocoaPods](https://cocoapods.org) is a dependency manager for Cocoa projects. You can install it with the following command:```ruby
$ gem install cocoapods
```
To integrate AppSymbol into your Xcode project using CocoaPods, specify it in your Podfile:```ruby
source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '12.0'
use_frameworks!target '' do
pod 'AppSymbol', '~> 1.0.0'
end
```
Then, run the following command:
```ruby
$ pod install
```### Swift Package Manager
[Swift Package Manager](https://swift.org/package-manager/) is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies.
> Xcode 11+ is required to build AppSymbol using Swift Package Manager.
```Swift
dependencies: [
.package(url: "https://github.com/MnkGitBox/AppSymbol.git", .upToNextMajor(from: "1.0.0"))
]
```### Manually
If you prefer not to use either of the aforementioned dependency managers, you can integrate AppSymbol into your project manually.
---
## Usage
- **SFSymbol**
1. Add symbol image files to assert folder with original SFSymbol name for older iOS versions.

2. Extend the `AppSymbolNames` to add type `AppSymbolNameType` variable with any name. And add variable value as original SFSymbol name.
```Swift
extension AppSymbolNames {var squareAndArrowUp: AppSymbolNameType { .init(rawValue: "square.and.arrow.up") }
}
```3. Finally, you can use this symbol file using the function provided by the framework.
```Swift
let shareButton = UIButton.init(with: .squareAndArrowUp, to: .systemFont(ofSize: 17, weight: .medium), for: .normal, scale: .medium)let shareImageView = UIImageView.init(.squareAndArrowUp, .systemFont(ofSize: 15, weight: .medium), scale: .medium)
```4. Result
- iOS 15.2 device
- iOS 12.0 device

- **Custom Symbol**
1. Even though Apple has provided thousands of different symbols in the SF Symbol library, it’s impossible to cover every conceivable image you may need in your app. What Apple has done instead is make it really easy for you to build your own custom symbols, when needed. (*You can find how to create custom symbol using the symbol template [here](https://developer.apple.com/documentation/uikit/uiimage/creating_custom_symbol_images_for_your_app).*)

2. Extend the `AppSymbolNames` to add type `AppSymbolNameType` variable with any name. And add variable value as original SFSymbol name.
```Swift
extension AppSymbolNames {
...static var lockOpenLine: AppSymbolNameType { .init(rawValue: "lock.open.line") }
}
```3. Finally, you can use this symbol file using the function provided by the framework.
```Swift
let shareButton = UIButton.init(with: .lockOpenLine, to: .systemFont(ofSize: 17, weight: .medium), for: .normal, scale: .medium)let shareImageView = UIImageView.init(.lockOpenLine, .systemFont(ofSize: 15, weight: .medium), scale: .medium)
```
4. Result
- iOS 15.2 device
- iOS 12.0 device

## Resources
You can find the original sample code [here](SampleCode.swift).
## Credits
- Malith Nadeeshan ([malithnadeeshan](https://twitter.com/malithnadeeshan))## License
AppSymbol is released under the MIT license. See LICENSE for details.