Swiftly convert country codes and other unique strings to emoji flags
let usa = "us".flag() // "🇺🇸"
let england = "gb-eng".flag() // "🏴"
let un = "un".flag() // "🇺🇳"
let chequered = "chequered".flag() // "🏁"
Check out the Veximoji-Example
iOS app.
Simply follow standard SPM conventions:
package(url: "https://github.com/roz0n/Veximoji.git", from: "2.0.0")
to your application's Package.swift
file.File > Swift Packages > Add Package Dependency
from the status bar menu.https://github.com/roz0n/Veximoji.git
and click Next
.Up to Next Major
is a safe default which accepts any version up to the next major release, click Next
to proceed.Once the package finishes downloading, should now see it listed in the Project Navigator on the left-hand pane. Likewise, feel free to select the project file, and Veximoji
should be listed under the Swift Packages
tab. Xcode will also automatically add it to your main project target under the "Frameworks, Libraries, and Embedded Content" header.
CocoaPods support is in the works.
The Veximoji
API is very concise and well-documented. It organizes emoji flags into four distinct categories:
Category | Definition | Example |
---|---|---|
country |
flags for countries with an ISO 3611-1 alpha-2 code | JP |
subdivision |
flags for subdivisions with an ISO 3611-2 code | GB-ENG |
international |
flags for exceptionally reserved ISO 3166-1 alpha-2 codes | EU or UN |
unique |
flags not related to individual countries or subdivisions | .pirate or "pirate" |
Each of the above categories are available in array-form via publicly exposed short-hand variables:
typealias EmojiFlagCategory
Veximoji.FlagCategories
, an enum representing the above categories.EmojiFlagCountryCodes: [String]
EmojiFlagSubdivisionCodes: [String]
EmojiFlagInternationalCodes: [String]
String.flag(term:) -> String?
FlagCategory
.country(code:) -> String?
subdivision(code:) -> String?
Code | Flag |
---|---|
GB-ENG |
🏴 |
GB-SCT |
🏴 |
GB-WLS |
🏴 |
international(code:) -> String?
Code | Flag |
---|---|
EU |
🇪🇺 |
UN |
🇺🇳 |
unique(term:) -> String?
.pride
or "pride"
refers to the rainbow or pride flag.Case | Raw value | Flag |
---|---|---|
.pride |
“pride” |
🏳️🌈 |
.trans |
“trans” |
🏳️⚧️ |
.pirate |
“pirate” |
🏴☠️ |
.white |
“white” |
🏳️ |
.red |
“red” |
🚩 |
.black |
“black” |
🏴 |
.crossed |
“crossed” |
🎌 |
.chequered |
“chequered” |
🏁 |
In the event you would like to validate any of the above manually, validation methods are publicly exposed for your convenience.
validateISO3166_1(code:) -> Bool
CFLocaleCopyISOCountryCodes
collectionvalidateISO3166_2(code:) -> Bool
validateExceptionalReservation(code:) -> Bool
"EU"
and "UN"
exceptionally reserved codes are supported as they are the only codes with iOS-supported emoji flagsEmail me at: [email protected]
MIT
link |
Stars: 5 |
Last commit: 1 year ago |
Full Changelog: https://github.com/roz0n/Veximoji/compare/2.0.0...2.1.0
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics