SwiftFlags

2.0.0

Get emoji flag from a country name or country code (ISO 3166-1)
andreabusi/SwiftFlags

What's New

2.0.0

2026-03-13T14:11:59Z

SwiftFlags 2.0.0

Full Changelog: 1.2.0...2.0.0

Breaking Changes

  • Dropped CocoaPods support. SwiftFlags is now distributed exclusively via Swift Package Manager.

Changes

  • Rebuilt the sample app from scratch using SwiftUI
  • Improved Package.swift definition
  • Updated documentation and README

Migration

If you were using CocoaPods, switch to Swift Package Manager by adding SwiftFlags to your project's package dependencies:

.package(url: "https://github.com/AEandruzzzi/SwiftFlags.git", from: "2.0.0")

SwiftFlags

CocoaPod version Apple Platforms Language

SwiftFlags is a simple library to get emoji flag from a country name or a country code (ISO 3166-1).

Usage

SwiftFlags comes with some static methods that you can use:

class func flag(for country: String) -> String?
class func countryCode(for country: String) -> String?

Examples

Here are some examples to get the emoji flag for a country. You can pass both a country name or a country code:

// Returns 🇮🇹
let _ = SwiftFlags.flag(for: "italy")
// Returns 🇺🇸
let _ = SwiftFlags.flag(for: "United States")
// Returns nil
let _ = SwiftFlags.flag(for: "England")
// Returns 🇯🇵
let _ = SwiftFlags.flag(for: "JP")
// Returns 🇰🇷
let _ = SwiftFlags.flag(for: "Korea, South")

SwiftFlags also provide the ability to return the ISO country code for a given country:

// Returns 'IT'
let _ = SwiftFlags.countryCode(for: "italy")
// Returns 'US'
let _ = SwiftFlags.countryCode(for: "United States")
// Returns nil
let _ = SwiftFlags.countryCode(for: "England")

Requirements

The latest version of SwiftFlags require:

  • Swift 5
  • XCode 11+ (in order to use Swift Package Manager)

Installation

SwiftFlags is available via CocoaPods, Swift Package Manager or you can directly embeed the library inside your project.

CocoaPods

Add the following to your Podfile:

pod 'SwiftFlags'

Swift Package Manager

Add the repo URL using the Swift Package Manager built inside Xcode:

https://github.com/BubiDevs/SwiftFlags.git

Manual installation

Just drag and drop the files under the Sources folder inside your project.

Credits

This library is based on the work of two existing library:

Thanks guys for your work!

ToDo

  • Add Swift Package Manager support
  • Improve ObjC interoperability

Description

  • Swift Tools 5.2.0
View More Packages from this Author

Dependencies

  • None
Last updated: Mon Apr 06 2026 21:01:47 GMT-0900 (Hawaii-Aleutian Daylight Time)