Swiftpack.co - Package - piknotech/SFSafeSymbols

Build Status Swift: 5.1 Version: 0.4.0 Platforms: iOS – tvOS – watchOS License: MIT
SwiftPM: Compatible Accio: Supported Carthage: Compatible CocoaPods: Compatible

MotivationInstallationUsageContributingLicenseIssuesPull Requests

Motivation

At WWDC 2019, Apple announced a new library of icons that come included with iOS 13. To browse them, there's even a dedicated Mac app called SF Symbols. However, developers still have to copy the name of an icon and reference it unsafely, resulting in code like this:

UIImage(systemName: "circle.fill")

It didn't take long until first ideas came up to make these icons accessible in a safe way using a framework. And this is just what SFSafeSymbols does!

Installation

SFSafeSymbols can be installed via Swift Package Manager, Accio, Carthage or CocoaPods.

Supported platforms are iOS (11.0+), tvOS (11.0+) and watchOS (6.0+), although the actual functionality is of course only accessible starting with iOS 13.0, tvOS 13.0 and watchOS 6.0.

Swift Package Manager

To integrate using Apple's Swift package manager, add the following as a dependency to your Package.swift:

.package(url: "https://github.com/piknotech/SFSafeSymbols.git", .upToNextMajor(from: "0.4"))

After specifying "SFSafeSymbols" as a dependency of the target in which you want to use it, run swift package update.

Accio

Do the same configurations as for SwiftPM, then run accio update instead of swift package update.

Carthage

Add the following entry to your Cartfile:

github "piknotech/SFSafeSymbols" ~> 0.4

Then run carthage update.

CocoaPods

Add the following entry to your Podfile:

pod 'SFSafeSymbols', '~> 0.4'

Then run pod install.

Usage

All the system icons are accessible via the SFSymbol enum. They are named similar to Apple's names, but use a lower camel case style and prefix names with leading numbers with a _ character:

c.circle        ~> SFSymbol.cCircle
e.circle.fill   ~> SFSymbol.eCircleFill
11.circle.fill  ~> SFSymbol._11CircleFill

A SF Symbol UIImage can now be initialized using the SFSymbol enum. This image is already unwrapped, so you get a UIImage instead of a UIImage?:

UIImage(systemSymbol: .cCircle)
UIImage(systemSymbol: SFSymbol.eCircleFill)
UIImage(systemSymbol: ._11CircleFill, withConfiguration: /* Some UIImage.Configuration */)

A SF Symbol SwiftUI.Image can also be initialized using the SFSymbol enum. It's also unwrapped, so you get a SwiftUI.Image instead of a SwiftUI.Image?:

Image(systemSymbol: .cCircle)
Image(systemSymbol: SFSymbol.eCircleFill)

All symbols are tested via a CI, so you can be sure your code won't crash because an image couldn't be found!

Contributing

Contributions are very much welcome! See CONTRIBUTING.md for more information.

License

This library is released under the MIT License. See LICENSE.md for details.

Github

link
Stars: 277
Help us keep the lights on

Dependencies

Used By

Total:

Releases

0.4.0 - Jun 27, 2019

Added

  • None

Changed

Fixed

0.3.1 - Jun 22, 2019

Added

  • Extended support for SwiftUI.Image initializer to macOS, tvOS and watchOS platforms (By Eric Lewis)

Changed

0.3.0 - Jun 17, 2019

Added

0.2.0 - Jun 14, 2019

Added

Changed

Fixed

  • Fix tests for iOS 12 and below; instead of not compiling, the tests simply fail (By David Knothe)

0.1.1 - Jun 4, 2019

Make library static