Giter Club home page Giter Club logo

fontawesome.swift's Introduction

FontAwesome.swift

Build Status CocoaPods Compatible Carthage Compatible Platform License

Use Font Awesome in your Swift projects

To see the complete set of 3,978 icons in Font Awesome 5, please check the FontAwesome.com site.

Examples

Installation

Carthage

github "thii/FontAwesome.swift"

CocoaPods

pod 'FontAwesome.swift'

Note: If you install this using CocoaPods, the framework name will be FontAwesome_swift (there is an underscore).

Manually

  • Drag and drop all .otf and .swift files into your project

Requirements

iOS 8 or later.

Development

After cloning, initialise the submodule to prepare for updating FontAwesome

git submodule init
git submodule update

To update this project to include all the latest icons from the new verison of Font Awesome (replace x.y.z with the new font version):

bundle exec fastlane update_font version:x.y.z

To release a new version x.y.z (replace x.y.z with a real version number):

bundle exec fastlane release version:x.y.z

Since it will automatically make a new commit to bump version and push to CocoaPods trunk, make sure you have write access to this repo and be one of the podspec owners. If you are a maintainer but don't have these privilege yet, please let me know.

License

  • All font files licensed under SIL OFL 1.1
  • FontAwesome.swift licensed under MIT

fontawesome.swift's People

Contributors

antonyalkmim avatar antranapp avatar dependabot[bot] avatar doedje avatar dwaynecoussement avatar himaratsu avatar imperiopolis avatar katunch avatar lukasackee avatar lukashromadnik avatar marcelofabri avatar matrixsenpai avatar moelnaggar14 avatar morizotter avatar mpclarkson avatar nanoxd avatar novinfard avatar olafandreas avatar oliverdowling avatar pib02 avatar rbresjer avatar readmecritic avatar rich86man avatar sandeepbol avatar shams-ahmed avatar szehnder avatar thii avatar tulleb avatar xslim avatar ykphuah 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  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  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

fontawesome.swift's Issues

Question mark instead of icon

Hi, I have small problem. After installation FontAwesome by using CocoaPoads I have seen question marks in rectangle instead of icon. I don't know why ... ?

UIImage.fontAwesomeIconWithName not working

With this code I get "could not find member .MapMarker"
UIImage.fontAwesomeIconWithName(.MapMarker, textColor: UIColor.grayColor(), size: 20)

With this code I get "cannot invoke 'fontAwesomeIconWithName' with and argument list of type '(FontAwesome,UIColor,Int)'
UIImage.fontAwesomeIconWithName(.MapMarker as FontAwesome, textColor: UIColor.grayColor(), size: 20)

However I have no problem using
String.fontAwesomeIconWithName(.MapMarker)

Is this just me or is this a bug?

Swift 2 / iOS 9 support?

Hello,
when it is expected to have support for iOS 9 / xcode 7 and Swift 2?
Thanks for the great library!

Swift 2

Is there any plans to update this for Swift 2.0? I get errors when trying to compile in Xcode 7

OSX support

Is there anyway to get this to work with OS X?

watchOS support

Is watchOS support something that is on your roadmap? If not, would you accept a pull request?

Icon as UIView

I'm trying to set the disclosure indicator on a tableview to the FontAwesome CaretRight icon, which would be perfect for my app. Unfortunately I can't seem to do that because the .accessoryView property of the table cell must be of type UIView.

It would be great if this was an option in this pod. Thanks for considering it.

Repo name conflicts with run script

Since the repo's name includes .swift, certain run scripts can confuse this with a swift file and cause errors. Is it possible to change the name to something like FontAwesomeSwift or FontAwsome_swift to eliminate these errors?

No Such Module 'FontAwesome' in Swift Project

Hello,

I follow the installation guide:

  1. Add pod 'FontAwesome.swift' and run 'pod install'
  2. Add 'import FontAwesome' to the controller file

After that I did import FontAwesome in my viewcontroller, then Xcode gave me No such module 'FontAwesome' error message. Please help me :)

p.s. I use Xcode 6.3.2

Swift 2.3 Syntax issues

FontAwesome.swift:120:49: Value of optional type 'CGDataProvider?' not unwrapped; did you mean to use '!' or '?'?

FontAwesome/FontAwesome.swift:98:16: Value of optional type 'UIImage?' not unwrapped; did you mean to use '!' or '?'?

dyld: library not loaded: @rpath/libswiftSecurity.dylib crash

I have a problem with your library.
This is the Xcode's console:

dyld: Library not loaded: @rpath/libswiftSecurity.dylib
Referenced from: /private/var/mobile/Containers/Bundle/Application/524AE979-D123-455E-83CC-DB96E01BC348/FoodApp.app/Frameworks/FontAwesome_swift.framework/FontAwesome_swift
Reason: image not found

fatal error

hi
when i ruling program app crash
in line fontURL = bundle.URLForResource(name, withExtension: "otf", subdirectory: "FontAwesome.swift.bundle")!
error : fatal error: unexpectedly found nil while unwrapping an Optional value

can you help me ?

Font is not loaded until fontAwesomeOfSize is called

I have a UILabel in a Storyboard.
I set the font to FontAwesome in the storyboard.
When running the app, I set the text using String.fontAwesomeIconWithName, but I only see a squared ? [?]
However, if before that anywhere in the app I call UIFont.fontAwesomeOfSize (probably because it calls the FontLoader) then it work as expected.

Is there anyway to get this to work without calling UIFont.fontAwesomeOfSize explicitly?

Combining Fonts

Is it possible to use a label with text and a fontawesome icon in it? Or can a label only have a single font?

dispatch_once in fontAwesomeIconWithName is not effective / token is not static

The "dispatch_once" call inside of "fontAwesomeIconWithName()" is not effective. The icons table is setup every time the function is called because the 'token' var itself is not static, which can result in poor performance if used frequently.

public extension String {
  public static func fontAwesomeIconWithName(name: String) -> String {
    var icons: [String: String]?
    var token: dispatch_once_t = 0    //  This is reset to 0 on every call, so 'dispatch_once' does nothing

    dispatch_once(&token) {
      icons = [
        "fa-adjust": "\u{f042}",...

If you debug this code (xcode debugger or just print), you will see that "token" is always 0 when the function is invoked. When using this function a lot, the performance was degraded surprisingly.

If you move the token / dictionary out to static symbols, the performance improves to expected levels.

need fontAwesomeIconWithUnicode

For some reason my php sends me article icons got from fontawesome.io lists
f0f6 (this is plain string, not Unicode character)

to convert it to \u{f0f6}" (singleUnicode character) I have to do:

let t="f0f6" //got this icon from server
let c=Int(strtoul(t, nil, 16))
let ch=Character(UnicodeScalar(c))
var s=""
s.append(ch)
iconLabel.text = s

I think we need func doing this, a kind of String.fontAwesomeIconWithUnicode

crash on FontAwsome file loading

I added the FontAswome in swift using cocoa pods.
In file FontAwsome.swift on line no 29
let fontURL = bundle.URLForResource(name, withExtension: "otf")
fontURL is always nil, thats why application is crashing.

Using other icons

Thanks for this great library.

But How do you use icons like fa-angle-up?

I tried button.setTitle(String.fontAwesomeIconWithName(.fa-angle-up), forState: .Normal) but failed

Add FontAwesomeView

I implemented a view that can be used directly in the storyboard and set which icon to use.

captura de tela 2016-06-28 as 04 59 33

Let me know if you'd like me to submit a PullRequest.

3 dots instead of icon

Hi, I'm experience some problems where I see 3 dots as ". . ." instead of the actual icon. Any suggestion on where might be the problem?

fontAwesomeIconWithCode

Hi there

I've written an extension that accepts Fontawesome css codes eg "fa-circle", as follows:

let icon = String.fontAwesomeIconWithCode("fa-circle")

Let me know if you'd like me to submit a PR.

Carthage cannot from current master

Xcode: 7.2.1, Build version 7C1002
Carthage: 0.15.1

Contents of Cartfile: github "thii/FontAwesome.swift"

*** Building scheme "FontAwesome" in FontAwesome.xcodeproj
** BUILD FAILED **


The following build commands failed:
    CompileSwift normal arm64 /Users/rb/Projects/AFTR/aftr-ios/AFTR/Carthage/Checkouts/FontAwesome.swift/FontAwesomeTests/FontAwesomeTests.swift
    CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
(2 failures)
/Users/rb/Projects/AFTR/aftr-ios/AFTR/Carthage/Checkouts/FontAwesome.swift/FontAwesomeTests/FontAwesomeTests.swift:25:18: error: module 'FontAwesome' was not compiled for testing
A shell task failed with exit code 65:
** BUILD FAILED **


The following build commands failed:
    CompileSwift normal arm64 /Users/rb/Projects/AFTR/aftr-ios/AFTR/Carthage/Checkouts/FontAwesome.swift/FontAwesomeTests/FontAwesomeTests.swift
    CompileSwiftSources normal arm64 com.apple.xcode.tools.swift.compiler
(2 failures)

Swift 3.0 compatibility errors

  • FontAwesome.swift:37:36: dispatch_once_t is unavailable in Swift: Use lazily initialized globals instead
  • FontAwesome.swift:41:19: fontNamesForFamilyName has been renamed to fontNames(forFamilyName:)
  • FontAwesome.swift:59:21: Value of type String has no member substringToIndex
  • FontAwesome.swift:71:45: Missing argument label name: in call
  • FontAwesome.swift:85:136: clearColor() has been renamed to clear()
  • FontAwesome.swift:87:47: Center has been renamed to center
  • FontAwesome.swift:93:32: NSAttributedString has been renamed to AttributedString
  • FontAwesome.swift:98:16: Value of optional type UIImage? not unwrapped; did you mean to use ! or ??
  • FontAwesome.swift:106:22: NSBundle has been renamed to Bundle
  • FontAwesome.swift:117:42: NSURL is not implicitly convertible to URL; did you mean to use as to explicitly convert?
  • FontAwesome.swift:124:35: CFStringRef has been renamed to CFString

Does not work with Carthage at version 0.7.0

simulator screen shot jan 27 2016 10 08 55 pm

I try use your lib with carthage :), unfortunately the awesome texts always wrong
my codes
self.navigationItem.rightBarButtonItem = UIBarButtonItem(title: String.fontAwesomeIconWithName( FontAwesome.PlusSquare), style: .Plain, target: self, action: "createNote")
self.title = String.fontAwesomeIconWithName(.Github)

Please give me an advise to solve this.

Thanks,

Add support for Carthage

It would be nice if this package could be installed via Carthage. I don't like copy&pasting source code into my projects...

Keep up the good work!

cocoapods 1.0.0 crash

Hi, since I updated to cocopods 1.0.0
I receive this crash

screen shot 2016-05-16 at 23 20 23

Please advice

this is my podfile

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '8.0'
use_frameworks!

target 'MyApp' do
pod 'ECSlidingViewController', '> 2.0.3'
pod 'AFNetworking', '
> 2.5'
pod 'PNChart', '~> 0.7.1'
pod 'FontAwesome.swift'
end

Add support to UIButton

I have tried this framework to work with UIButton but I haven't been able to find a way around it to make it work.. Not sure if it supports UIButton yet but if it does it might be great to have an example in the readme file.

Thanks in advance!

don't show icon in swift2

i have v0.6 and import FontAwesome_swift or import FontAwesome

When i use this lib for show icon:
self.title = String.fontAwesomeIconWithName(.Android)
i have the next result:
captura de pantalla 2015-09-25 a las 11 34 51

Any idea?

Hi) How to fix this code to instead of the text was an icon

Hi!
How to fix this code to instead of the text was an icon?

@IBAction func btnApple(sender: UIButton) {
        sender.enabled = false
        sender.titleLabel?.font = UIFont.fontAwesomeOfSize(20)
        sender.titleLabel?.textColor = UIColor.blackColor()
        sender.setTitle(String.fontAwesomeIconWithName(.Apple), forState: .Normal)
}

Thank you)

Issues in Swift 2.0

I am seeing two errors in Swift 2.0:

FontAwesome.swift
line 39: as should be as!
line 659: advance should be advancedBy

Doesn't work for Mac target

Carthage says:

Dependency "FontAwesome.swift" has no shared framework schemes for any of the platforms: Mac

If you believe this to be an error, please file an issue with the maintainers at https://github.com/thii/FontAwesome.swift/issues/new

Looking at a bit of the source, it looks like it uses UIKit, but perhaps it is worth having this work on Mac as well. Thoughts?

Error during build

During build (debug) I receive such errors:

egrep: .../Pods/FontAwesome.swift: Is a directory
egrep: .../Pods/Target Support Files/FontAwesome.swift: Is a directory

Command /bin/sh emitted errors but did not return a nonzero exit code to indicate failure

In fact, project name generates it. What can we do with it not to have this error?


Xcode 7.3.1
FontAwesome.swift (0.7.3)

problem in run app

hi, I have a problem, when I run the app, the compiler get an error in this line of fontAwesome.swift : "let data = NSData(contentsOfURL: fontURL!)!"

i think this error happen for link of font and class, isn't it?

Loading Tab Bar Images On Load

I have a line in each of my view controllers to set the tab bar image. This is fine, but only works once you've clicked the tab. Is there anyway to load the images with the tab bar controller so they are loaded on the tab bar controller load?

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.