Code Monkey home page Code Monkey logo

faswiftui's Introduction

FASwiftUI

Easily integrate FontAwesome 5 or 6 into your SwiftUI projects. Use Font Awesome icons as text in your SwiftUI views. Supports Font Awesome Pro or Free.

(Does not currently support the Duotone style.)

Installation - Swift Package Manager


  1. Add the Swift package to your Xcode project
    1. File -> Swift Packages -> Add Package Dependency
    2. Enter https://github.com/mattmaddux/FASwiftUI.git
  2. Download Font Awesome
    1. Go to https://fontawesome.com/download
    2. Download the Pro or Free version
  3. Drag the following files from the download to your project:
    • icons.json AND EITHER
      • Font Awesome 6 Brands-Regular-400.otf
      • Font Awesome 6 [Free/Pro/Sharp]-Regular-400.otf
      • Font Awesome 6 [Free/Pro/Sharp]-Solid-900.otf
      • Font Awesome 6 [Pro/Sharp]-Light-300.otf (Pro Only) OR
      • Font Awesome 5 Brands-Regular-400.otf
      • Font Awesome 5 [Free/Pro]-Regular-400.otf
      • Font Awesome 5 [Free/Pro]-Solid-900.otf
      • Font Awesome 5 Pro-Light-300.otf (Pro Only)
  4. Add files to target - For each of the files in the last step:
    1. Select the file in Project Navigator
    2. Open the Inspectors bar on the right and select the file inspector (first tab)
    3. Under Target Membership select each target you need to use FASwiftUI
  5. Add Fonts to Info.plist
    1. Open your project's info.plist
    2. Right-Click in a blank area and choose "Add Row"
    3. Name the new entry "Fonts provided by application"
    4. Expand the entry by clicking the triangle to the left
    5. Add a new entry for each of the "otf" files you added to your project, using the full filename including the extension
  6. You're done!

Usage


Use a Font Awesome icon in any view:

import SwiftUI
import FASwiftUI

struct ContentView: View {
    var body: some View {
        FAText(iconName: "bomb", size: 200)
    }
}

Regualr Icon Screenshot

You can also choose an alternate style. (This is ignored if the icon is a brand and currently duotone is not supported and will default back to regular.)

import SwiftUI
import FASwiftUI

struct ContentView: View {
    var body: some View {
        FAText(iconName: "bomb", size: 200, style: .solid)
    }
}

Regualr Icon Screenshot

Set the color as you would any text.

import SwiftUI
import FASwiftUI

struct ContentView: View {
    var body: some View {
        FAText(iconName: "bomb", size: 200)
            .foregroundColor(Color.red)
    }
}

Regualr Icon Screenshot

faswiftui's People

Contributors

heyjones avatar kdo1234 avatar martyuiop avatar mattmaddux avatar zalarudo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

faswiftui's Issues

Add fallback and error logging for missing styles and incorrect names

i've

  • added package dependancy
  • copied icons.json and three font files *.otf to my project
  • added them to the target
  • added to info.plist new section "Fonts provided by application" with three items (like 'Font Awesome 5 Brands-Regular-400.otf' without quotation)
  • i've added "FAText(iconName: "bomb", size: 50)" to the view
  • and all what i see is a question icon

Screenshot 2020-02-17 at 18 14 14

what am i doing wrong? could you help me?

Accessing Search function requires public on init

Unable to access the search function from package unless adding public to the init of the public class.
Possible you had another mechanism for using the search? if not, one word fix. or I can submit a PR

eg.

let mySearch = FontAwesome().search(query: symbolSearch.lowercased())
results in
'FontAwesome' initializer is inaccessible due to 'internal' protection level
Even though FontAwesome class is public because init is not explicitly public also
adding 'public' to the init() corrects this

Some icons shows as question mark

Some icons are shown as question marks.
What I did:

  1. Installed the package.

Снимок экрана 2022-05-04 в 17 46 17

  1. Connected all the files in the inspector

Снимок экрана 2022-05-04 в 17 46 39

  1. put all data into info plist

Снимок экрана 2022-05-04 в 17 47 01

As Result some icons are Questions& In this example its "running" icon
Снимок экрана 2022-05-04 в 17 48 13

Version FA - 5.15.4 For The Desktop
Version xCode - 13.2.1

About QGrid dependencies

Hi, first of all, thank you so much for this library, it saved me a lot of time and nerves
In the dependency file, I found the QGrid library, which is installed with the package, but I didn't find its use in the code itself. The thing is that it is quite heavy and the size of the project increased by 50 megabytes. Please tell me if you need it for your tool or it can be removed?

Missing support for Sharp font style

Our project requires the use of sharp fonts:

sharp-solid-900
sharp-regular-400
sharp-light-300

I'm going to create a fork and attempt to add support for these myself.

Won't display in TabView

Is there any way these can be used in the TabView? When I try to use them on there, All I see is a small box with ? in it.

LICENSE

Hey, this repo is missing a License file, I wanna know if I can copy and modify this code.

Swift Package not pulling down latest commit

Hi Matt,

The Swift Package only pulls down the new FA6 code if specifying the specific branch. Not done much with Swift Package but presuming it just needs a version update?

Thanks
martyuiop

Target Membership

After I install FASwiftUI it does not show up in the Target Membership section so I'm not able to select it. What could I possibly do to fix this?

Question Marks only

Followed the integration steps in the readme and everything went well, however when I try to use the icons I only get the question mark in a box. I've tried "bluetooth-b", "signal", and "bomb" used in your example. I've also tried to prefix these with the "fa-" with no luck.

in iOS 14 widgets I have crash with "Terminated due to memory error."

When I run my widget in iOS simulator I seems like ok, but when I run it in real device I have crash with "Terminated due to memory error." error in console. When I disable "FAText" its works fine (but without icons). I think this happens because the icons.json file weighs more than 14 megabytes and when lib trying to decode the file into an object it wastes a lot of memory. Do you think there is a way to solve this problem?
in my case I use only solid pro icons

Fatal error in Initializer

Hi Matt,

when using your Package i get the error: Fatal error: Unexpectedly found nil while unwrapping an Optional value
it appears in class FontAwesome line 30.
let fileURL = Bundle.main.url(forResource: "icons", withExtension: "json")!

Xcode 12 Beta Crash

I'm not sure if this is because I am using a beta of Xcode, but wanted to report a crash when using this via SPM. When I use

FAText(iconName: "bomb", size: 200).foregroundColor(Color.red)

let fileURL = Bundle.main.url(forResource: "icons", withExtension: "json")! will crash with trying to access a nil value. I hope to dig a little deeper, but as far as the app is concerned icons.json does not exist.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.