A better way to operate icon font in Swift, support iOS, macOS, watchOS and tvOS.





GitHub Stars



Last Commit

2mos ago










An ordinary iconfont cocoapods package helps you to use iconfont more easily in your project, in Swift.






You can click the TestFlight button below to download demo with TestFlight:

Compile Demo Manually

To run the example project manually, clone the repo, and run sh Startup.sh in project folder. Demo is in the Example folder, open Example.xcworkspace with Xcode and select the target you want in it, run.

Or you can run the following command in terminal:

git clone git@github.com:EFPrefix/EFIconFont.git; cd EFIconFont; sh Startup.sh; open Example/Example.xcworkspace;


<0.5Xcode 10.0+
Swift 4.2+
iOS 8.0+
>=0.5Xcode 10.2+
Swift 5.0+
iOS 8.0+



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

pod 'EFIconFont'

You can get built-in iconfonts with subspecs, for example you will get icons of AntDesign and FontAwesome by the following way:

pod 'EFIconFont', :subspecs => ['AntDesign', 'FontAwesome']

You can also choose to get all built-in packs by using Complete subspec:

pod 'EFIconFont', :subspecs => ['Complete']

Then, run the following command:

pod install

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the Swift compiler.

Once you have your Swift package set up, adding EFIconFont as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/EFPrefix/EFIconFont.git", .upToNextMinor(from: "1.2.0"))


1. Core

Objects that implement the EFIconFontProtocol protocol can transform themselves into NSAttributedString or UIImage, which is as follows:

public protocol EFIconFontProtocol {

    // `name` is not necessarily equal to .ttf file name
    var name: String { get }

    // `path` is path of .ttf file
    var path: String { get }

    // `attributes` is style of icon
    var attributes: [NSAttributedString.Key : Any] { set get }

    // `unicode` is unique identifier of particular icon
    var unicode: String { get }
    // `font` is UIFont of icon with input font size
    func font(size fontSize: CGFloat) -> UIFont?
  • name: Font name, not necessarily equal to .ttf file name, you can use BirdFont to see the Name attribute of the file;
  • path: Filepath of .ttf file, usually you can get it through code like Bundle.main.path(forResource: name, ofType: "ttf")(If filename is same as name, you can use the default implementation and do not need to implement this property);
  • attributes: Attributes of icon(You can use the default implementation and do not need to implement this property);
  • unicode: The unique unicode of an icon;
  • font: The UIFont of an icon with input font size.

Objects that implement the protocol can be converted to strings and images by calling the following methods, you can also change the foreground color and size:

// MARK:- String
func attributedString(size fontSize: CGFloat, attributes: [NSAttributedString.Key : Any]?) -> NSAttributedString?
func attributedString(size fontSize: CGFloat, foregroundColor: UIColor? = nil, backgroundColor: UIColor? = nil) -> NSAttributedString?

// MARK:- Image
func image(size fontSize: CGFloat, attributes: [NSAttributedString.Key : Any]?) -> UIImage?
func image(size fontSize: CGFloat, foregroundColor: UIColor? = nil, backgroundColor: UIColor? = nil) -> UIImage?
func image(size imageSize: CGSize, attributes: [NSAttributedString.Key : Any]?) -> UIImage?
func image(size imageSize: CGSize, foregroundColor: UIColor? = nil, backgroundColor: UIColor? = nil) -> UIImage?

2. Built-in iconfont packs

This pod has integrated some free resources in the subspecs, like AntDesign and FontAwesome. It can be imported by who need to use it. The usage methods are as follows, you can get a return value of EFIconFontProtocol:


You can use the object which follow EFIconFontProtocol to get NSAttributedString and UIImage:

EFIconFontAntDesign.addteam.attributedString(size: 24)
EFIconFontFontAwesomeBrands.adobe.attributedString(size: 32, foregroundColor: UIColor.white, backgroundColor: UIColor.green)
EFIconFontFontAwesomeRegular.addressBook.image(size: 24, foregroundColor: UIColor.red)
EFIconFontFontAwesomeSolid.alignLeft.image(size: CGSize(width: 36, height: 48), foregroundColor: UIColor.white)

You can also get all icons of a EFIconFontCaseIterableProtocol object with type [String : EFIconFontProtocol] by the following code:


PS: Although the libraries below are all free, please make sure that your way of using the icon conforms to the original author's protocol specification:

NameVersionCountFile SizeDescriptionLicensePreview
AntDesign1.0557127KBAnt DesignMITiconfont.cn
Dashicons0.9.020351 KBOfficial icon font of the WordPress adminGPLv2wordpress.org
Devicons1.8.019292KBAn iconic font for developersMITvorillaz.github.io/devicons
ElusiveIcons2.0.030453KBElusive IconsOFLelusiveicons.com
EvilIcons1.10.17016 KBSimple and clean SVG icon packMITevil-icons.io
FontAwesom(Regular / Brands / Solid)5.8.11516356KBFont AwesomeFont Awesome Free Licensefontawesome.com
FoundationIcons3.028368KBFoundation Icon Fonts 3-zurb.com/playground/foundation-icon-fonts-3
Genericons4.0.410316KBGenericons Neue are generic looking icons, suitable for a blog or simple websiteGPLv2genericons.com
Hawcons1.01035685KBHawcons, includes icons of Documents, Sports, Weather, Emoji, Gestures, Filetypes, etc.Freehawcons.com
IcoMoon1.049094KBIcoMoon free iconsCC BY 4.0 / GPLionicons.com
LigatureSymbols2.1123984KBLigature SymbolsOFLkudakurage.com/ligature_symbols
MapIcons3.0.019248 KBA set of icons for use with mapsOFLmap-icons.com
MaterialIcons3.0.11057695KBGoogle's material design icons, four stylesApache-2.0material.io
Meteocons4715KBA set of weather icons, it containing 40+ iconsFreealessioatzeni.com/meteocons
MetrizeIcons1.030074KBFree Collection of 300 Metro-Style Icons for Designers and DevelopersFreealessioatzeni.com/metrize-icons
OpenIconic1.1.122333KBAn open source icon set with 223 marks in SVGOFLuseiconic.com/open
StrawberryIcon2.0.038269KBA Free And Open Iconic Font Library for Developer and CreatorOFLchuangzaoshi.com/icon
Stroke71.2.020244KBA series of iOS 7 inspired thin stroke iconsFreethemes-pixeden.com/font-demos
ThemifyIcons1.035268KBA complete set of icons for use in web design and appsFreethemify.me
Typicons2.0.933682KB336 pixel perfect, all-purpose vector icons in a kitOFLs-ings.com/typicons
VSCodeIcons1.013324KBIcons for Visual Studio CodeMITgithub.com/microsoft/vscode-icons
WeatherIcons2.0.1021964KBWeather, maritime, and meteorological based iconsOFLerikflowers.github.io/weather-icons
Zocial1.3.011231KBPopular social iconsMITsmcllns.github.io/css-social-buttons/

3. Extend custom packs

(1) Import Font File

Drag the .ttf file of the icon library into the Xcode project and ensure that the Copy Bundle Resources list in Build Phases contains this font file (It will be included by default, just check it).

In addition, the file will be loaded at runtime, do not need to add it to the Fonts provided by application item in the Info.plist file.

(2) Implement EFIconFontCaseIterableProtocol

By making a implementation of EFIconFontCaseIterableProtocol you can get your custom iconfont pack object, demo in this project demonstrates customization with GitHub's Octicons as an example:

import EFIconFont

public extension EFIconFont {
    public static let octicons = EFIconFontOcticons.self

extension EFIconFontOcticons: EFIconFontCaseIterableProtocol {
    public static var name: String {
        return "octicons"
    public var unicode: String {
        return self.rawValue

public enum EFIconFontOcticons: String {
    case thumbsup = "\u{e6d7}"
    case unverified = "\u{e6d6}"
    case unfold = "\u{e6d5}"
    case verified = "\u{e6d4}"
    // ...

(3) Call

Same as Built-in iconfont packs above:


(4) Attention

The Octicons icon library in this project is owned by GitHub. This is only a demonstration, do not use it in any situation that violates the specifications set by its owner:

NameVersionCountFile SizeDescriptionLicensePreview
Octicons8.4.218434KBGitHub‘s iconsGitHub Logos and Usageocticons.github.com

4. Other

Usage of some iconfont resource sites:


EyreFree, eyrefree@eyrefree.org


EFIconFont is available under the MIT license. See the LICENSE file for more info.

Rate & Review

Great Documentation0
Easy to Use0
Highly Customizable0
Bleeding Edge0
Responsive Maintainers0
Poor Documentation0
Hard to Use0
Unwelcoming Community0