mirror of
https://github.com/brzzdev/FlagEmojis.git
synced 2026-05-16 23:00:26 +00:00
FlagEmojis is a single-file library for matching country code/names to their respective emojis
- Swift 95.9%
- Just 3.9%
- Shell 0.2%
|
|
||
|---|---|---|
| .github/workflows | ||
| .scripts | ||
| Sources/FlagEmojis | ||
| Tests/FlagEmojis | ||
| .git-format-staged | ||
| .gitignore | ||
| .swiftlint.yml | ||
| .swiftlint_child.yml | ||
| CLAUDE.md | ||
| justfile | ||
| Mintfile | ||
| Package.swift | ||
| README.md | ||
| renovate.json | ||
FlagEmojis
FlagEmojis is a single-file Swift library for matching country code/names to their respective emojis
API
public static func flag(for country: String) -> String?
public static subscript(country: String) -> String?
public static func countryCode(for country: String) -> String?
Example Usage
FlagEmojis.flag(for: "italy") // 🇮🇹
FlagEmojis["United Kingdom"] // 🇬🇧
FlagEmojis["States"] // nil (Too ambiguous)
FlagEmojis.countryCode(for: "Germany") // DE
Installation
SPM
Targets
- From the File menu, select Add Package Dependencies...
- Enter "https://github.com/brzzdev/FlagEmojis" into the package repository URL text field
Package.swift
.package(
url: "https://github.com/brzzdev/FlagEmojis",
from: "1.0.0"
),
Manual
Add the file to your project, or copy and paste to your hearts desire
Credit
Heavily based on SwiftFlags, which itself credits country-emoji, and flag-emoji-from-country-code 💜