Swiftpack.co - LiveUI/Awesome as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by LiveUI.
LiveUI/Awesome 2.4.0
FontAwesome 6 Swift & SwiftUI implementation for iOS, tvOS & macOS
⭐️ 73
🕓 23 weeks ago
iOS macOS watchOS tvOS
.package(url: "https://github.com/LiveUI/Awesome.git", from: "2.4.0")

Awesome

Font Awesome Slack Version License Platform

Super easy to use library containing the brand new Font Awesome 6, completely redesigned for Swift 5

Slack

Get help using and installing this product on our Slack, channel #help-awesome

Installation

Awesome is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'AwesomeEnum'

for Carthage just add:

github "LiveUI/Awesome"

for Swift Package Manager

You can add in your project settings under Swift Packages or File -> Swift Packages -> Add Package to enter the following url and select version to complete.

https://github.com/LiveUI/Awesome

If you want to add in package.swift manifest file add under dependencies.

.package(url "https://github.com/LiveUI/Awesome", from: 2.0.0)

Usage

Import will be slightly different for Cocoapods/Carthage/SPM. Sorry for the confusion of names but some unreasonable fellow has already registered an Awesome pod before us :).

Cocoapods

import AwesomeEnum

Carthage

import Awesome

Swift Package Manager

import Awesome

All icons are available through autogenerated enums like this:

// UKit and AppKit
let image = Awesome.Solid.handScissors.asImage(size: 40.0)
// or
let image = Awesome.Brand.android.asImage(size: CGSize(width: 40, height: 40), color: .red, backgroundColor: .blue) // :trollface:
// or
let attributedText = Awesome.Regular.envelopeOpen.asAttributedText(fontSize: 17, color: .red, backgroundColor: .blue)

// SwiftUI
Awesome.Brand.apple.image
// Set some modifiers
Awesome.Brand.android.image
	.size(40)
	.foregroundColor(.red)
	.backgroundColor(.blue)
// Scales automatically with font
Awesome.Brand.android.image
    .foregroundColor(.red)
    .backgroundColor(.blue)
    .font(.largeTitle)
// or
Awesome.Image(icon: Awesome.Brand.apple)

Font Awesome Pro

The Font Awesome Free files are included and loaded for you out of the box. Font Awesome Pro licensing terms don't allow to publish the font files however, so we can't add those for you. As such you will need to manually add the fonts to your project and register them before using them:

// AppDelegate application(_:didFinishLaunchingWithOptions:)

// Load all fonts
AwesomePro.loadFonts(from: Bundle.main)

// Load only some fonts
AwesomePro.loadFonts(from: Bundle.main, only: [.brand, .solid])

//For registering fonts use Bundle.module
let resourceURLString = Bundle.module.url(forResource: fontName, withExtension: nil)

The filenames have to match Font Awesome's naming scheme (fa-brands-400.ttf, fa-light-300.ttf, fa-regular-400.ttf, fa-solid-900.ttf). You only have to include the fonts you are using.

Once the fonts are registered you can use the AwesomePro enum just as you'd use the Awesome enum, except that you now have access to all Font Awesome Pro icons.

Contributors

License

Awesome is available under the MIT license. See the LICENSE for more info. All fonts are property of Font Awesome!

GitHub

link
Stars: 73
Last commit: 1 week ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

6.0 support + SwiftUI
23 weeks ago

Thank you @divadretlaw

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics