Swiftly convert country codes and cultural terms to all 269 emoji flags without hassle

Overview


Swiftly convert ISO country codes (incl. subdivisions and exceptional reservations) and cultural terms to all 269 iOS-supported emoji flags without hassle.



vex·il·lol·o·gy (/ˌveksəˈläləjē/) noun: the study of flags.

From a developer's perspective, emojis are great. They're a vast collection of natively supported and recognizable icons with a wide variety of use cases. They enhance the visual appearance of labels and cells and do not require third-party dependencies.

Working with emojis in Swift is not as swifty as it could be, though. Veximoji aims to remedy that.

Demo

Checkout the Veximoji-Example iOS app.

Installation

Package installation follows traditional conventions.

Swift Package Manager

Manual Installation

Add package(url: "https://github.com/roz0n/Veximoji.git", from: "1.0.0") to your application's Package.swift file.

Via Xcode

  1. Open your project within Xcode and select File > Swift Packages > Add Package Dependency from the status bar menu.
  2. Paste the HTTPS Github link: https://github.com/roz0n/Veximoji.git and click Next.
  3. You'll be asked to define package options. 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

CocoaPods support is not yet available, but it's on the roadmap.

API

The Veximoji API is very concise and well-documented. It supports four different emoji flag 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
cultural flags not related to individual countries or subdivisions .pirate

Each emoji flag category has a method to obtain its flags.

Flag Category Methods

country(code:) -> String?

  • Used to render a country's emoji flag by its ISO 3611-1 alpha-2 code
  • Returns a string containing the corresponding flag emoji if the given country code is valid, otherwise returns nil
  • There is no need to manually check the validity of the given code as this method makes a call to validateISO3166_1(code:) already
  • For more information on ISO 3611 country codes visit this Wikipedia article.
Usage
if let flag = Veximoji.country(code: "DO")  {
  print("\(flag)") // "🇩🇴"
}

subdivision(code:) -> String?

  • Used to render a given subdivision’s emoji flag by its ISO 3611-2 code
    • For clarity: England, Scotland, and Wales are considered subdivisions of Great Britain
  • Returns a string containing the corresponding flag emoji if the given subdivision code is valid, otherwise returns nil
  • There is no need to manually check the validity of the given code as this method makes a call to validateISO3166_2(code:) already
  • For more information on ISO 3611-2 codes visit this Wikipedia article.
Supported Codes
Code Flag
GB-ENG 🏴󠁧󠁢󠁥󠁮󠁧󠁿
GB-SCT 🏴󠁧󠁢󠁳󠁣󠁴󠁿
GB-WLS 🏴󠁧󠁢󠁷󠁬󠁳󠁿
Usage
if let flag = Veximoji.subdivision(code: "GB-SCT")  {
  print("\(flag)") // "🏴󠁧󠁢󠁳󠁣󠁴󠁿"
}

international(code:) -> String?

  • Used to render the flag of an exceptionally reserved ISO 3166-1 alpha-2 code
  • Returns a string containing the corresponding flag emoji if the given exceptionally reserved code is valid, otherwise returns nil
  • There is no need to manually check the validity of the given code as this method makes a call to validateExceptionalReservation(code:) already
  • For more information on exceptionally reserved codes visit this Wikipedia article.
Supported Codes
Code Flag
EU 🇪🇺
UN 🇺🇳
Usage
if let flag = Veximoji.subdivision(code: "UN")  {
  print("\(flag)") // "🇺🇳"
}

cultural(term:) -> String?

In the context of Veximoji, cultural term refers to an emoji flag that does not correspond to a country or region, but rather to a cultural reference, movement, or ideology. For example, .pride refers to the "rainbow" or "pride" flag.

Veximoji contains the correct Unicode scalars needed to accurately render each emoji flag. Unlike the other flag category methods, it does not expect a string as input but instead references the publicly exposed CulturalTerms enum (which also supports raw values).

Supported Cases
Case Raw value Flag
.pride “pride” 🏳️‍🌈
.trans “trans” 🏳 ️‍⚧️
.pirate “pirate” 🏴‍☠️
.white “white” 🏳️
.black “black” 🏴
.crossed “crossed” 🎌
.triangular “triangular” 🚩
.racing “racing” 🏁
Usage
if let flag = Veximoji.cultural(term: .pride)  {
  print("\(flag)") // "🏳️‍🌈"
}

Code Validation Methods

In the event you would like to validate any of the above codes or terms manually for whatever reason, Veximoji exposes its validation methods for your convenience.

validateISO3166_1(code:) -> Bool

  • Returns a boolean indicating whether a given string is a supported ISO 3611 alpha-2 country code by checking whether or not it is contained within the CFLocaleCopyISOCountryCodes collection
  • For more information on supported country codes visit the CFLocaleCopyISOCountryCodes page in the Apple Developer Documentation
Usage
let dominicanRepublicCode = "do" // supports uppercase, lowercase, and mixed-case strings

if Veximoji.validateISO3166_1(code: dominicanRepublicCode)  {
  print("That code is valid")
} else {
  print("That code is invalid")
}

validateISO3166_2(code:) -> Bool

  • Returns a boolean indicating whether a given string is a valid ISO 3611-2 subdivision code
  • Currently, Veximoji only supports Great Britain’s subdivision codes as they are the only subdivisions with iOS-supported emoji flags
Usage
let scotlandCode = "gb-sct" // supports uppercase, lowercase, and mixed-case strings

if Veximoji.validateISO3166_2(code: scotlandCode)  {
  print("That code is valid")
} else {
  print("That code is invalid")
}

validateExceptionalReservation(code:) -> Bool

  • Returns a boolean indicating whether a given string is a valid ISO 3166-1 exceptionally reserved code.
  • Currently, Veximoji only supports EU and UN exceptionally reserved codes as they are the only codes with iOS-supported emoji flags
Usage
let euCode = "eu" // supports uppercase, lowercase, and mixed-case strings

if Veximoji.validateExceptionalReservation(code: euCode)  {
  print("That code is valid")
} else {
  print("That code is invalid")
}

Roadmap

  • Add support for exceptional reservations
  • Add support for subdivisions
  • CocoaPods support
  • Continually support new emoji flags as they are added to the Unicode standard and supported by Apple development platforms

Support

Feel free to email me at [email protected]

License

MIT

You might also like...
IconsMaker - Create your app icon with SwiftUI and generate PNG images in all needed sizes
IconsMaker - Create your app icon with SwiftUI and generate PNG images in all needed sizes

IconsMaker - Create your app icon with SwiftUI and generate PNG images in all needed sizes

ImagePicker : an all-in-one camera solution for your iOS app
ImagePicker : an all-in-one camera solution for your iOS app

Description ImagePicker is an all-in-one camera solution for your iOS app. It lets your users select images from the library and take pictures at the

A framework that lists all photos in the album that contain faces.

FaceCollectionViewKit A framework that lists all photos in the album that contain faces. Features It uses the detection features of CIDetectorTypeFace

Media view which subclasses UIImageView, and can display & load images, videos, GIFs, and audio and from the web, and has functionality to minimize from fullscreen, as well as show GIF previews for videos.
Media view which subclasses UIImageView, and can display & load images, videos, GIFs, and audio and from the web, and has functionality to minimize from fullscreen, as well as show GIF previews for videos.

I've built out the Swift version of this library! Screenshots Description ABMediaView can display images, videos, as well as now GIFs and Audio! It su

An extremely high-performance, lightweight, and energy-efficient pure Swift async web image loader with memory and disk caching for iOS and  Watch.

KFSwiftImageLoader KFSwiftImageLoader is an extremely high-performance, lightweight, and energy-efficient pure Swift async web image loader with memor

APNGKit is a high performance framework for loading and displaying APNG images in iOS and macOS.
APNGKit is a high performance framework for loading and displaying APNG images in iOS and macOS.

APNGKit is a high performance framework for loading and displaying APNG images in iOS and macOS. It's built on top of a modified version of libpng wit

FMPhotoPicker is a modern, simple and zero-dependency photo picker with an elegant and customizable image editor
FMPhotoPicker is a modern, simple and zero-dependency photo picker with an elegant and customizable image editor

FMPhotoPicker is a modern, simple and zero-dependency photo picker with an elegant and customizable image editor Quick demo Batch select/deselect Smoo

✂️ Detect and crop faces, barcodes and texts in image with iOS 11 Vision api.
✂️ Detect and crop faces, barcodes and texts in image with iOS 11 Vision api.

ImageDetect ImageDetect is a library developed on Swift. With ImageDetect you can easily detect and crop faces, texts or barcodes in your image with i

🍁🥓 Lightweight and fast Swift library for image downloading, caching and transformations
🍁🥓 Lightweight and fast Swift library for image downloading, caching and transformations

MapleBacon Introduction MapleBacon is a lightweight and fast Swift library for downloading and caching images. Example The folder Example contains a s

Comments
  • Release 2.1.0

    Release 2.1.0

    • Based refactoring
    • Added convenience variables and EmojiFlagCategory typealias
    • Eradicated all syntactic use of Veximoji.* anything
    • Cleaned up README a bunch
    opened by roz0n 0
  • Release 2.0.0

    Release 2.0.0

    Includes various improvements:

    • Added Veximoji.flag() convenience method
    • Adds all Veximoji methods as an extension of String for brevity
    • Renamed cultural flags (.racing -> .chequered, .triangular -> .red)
    • Added raw values to Veximoji.CulturalTerms to allow for string-based conversion of cultural terms to flags, for example "pride".flag() -> "🏳️‍🌈"
    • Renamed Veximoji.CulturalTerms to Veximoji.UniqueTerms
    • Updated documentation
    • Updated README
    opened by roz0n 0
  • Patch: Missing platform support, adjusts naming of flag

    Patch: Missing platform support, adjusts naming of flag "groups" enum

    • Adds support for watchOS and tvOS
    • Adds support for Swift 5.0, 5.1, 5.2, 5.3
    • FlagGroups, which was previously only used internally (but exposed publicly), has been renamed to FlagCategories for consistency. I'm making a one-time exception and not considering the latter a breaking API change or worthy of a minor version increment. In future versions, a change of this nature will likely be deemed as much.
    opened by roz0n 0
  • Add support for missing flags (GB-ENG, GB-WLS, EU, etc.)

    Add support for missing flags (GB-ENG, GB-WLS, EU, etc.)

    • Adds support for missing subdivision flags
    • Adds support for missing international flags
    • Refactors individual flag methods to use a single generic function
    • Updates internal documentation to reflect changes
    opened by roz0n 0
Releases(2.1.0)
  • 2.1.0(May 9, 2022)

    What's Changed

    • Release 2.1.0 by @roz0n in https://github.com/roz0n/Veximoji/pull/6

    Full Changelog: https://github.com/roz0n/Veximoji/compare/2.0.0...2.1.0

    Source code(tar.gz)
    Source code(zip)
  • 2.0.0(May 2, 2022)

    What's Changed

    • Release 2.0.0 by @roz0n in https://github.com/roz0n/Veximoji/pull/3
    • Update README.md after 2.0.0 release by @roz0n in https://github.com/roz0n/Veximoji/pull/4
    • Update README.md (again) by @roz0n in https://github.com/roz0n/Veximoji/pull/5

    • Added Veximoji.flag() convenience method
    • Adds all Veximoji methods as an extension of String for brevity
    • Renamed cultural flags (.racing -> .chequered, .triangular -> .red)
    • Added raw values to Veximoji.CulturalTerms to allow for string-based conversion of cultural terms to flags, for example "pride".flag() -> "🏳️‍🌈"
    • Renamed Veximoji.CulturalTerms to Veximoji.UniqueTerms
    • Updated documentation
    • Updated README

    Full Changelog: https://github.com/roz0n/Veximoji/compare/1.0.1...2.0.0

    Source code(tar.gz)
    Source code(zip)
  • 1.0.1(Jun 7, 2021)

    v1.0.1 Release ⌚

    • Adds support for watchOS and tvOS
    • Adds support for earlier Swift versions up to 5.0
    • FlagGroups, which was previously only used internally (but exposed publicly), has been renamed to FlagCategories for consistency. I'm making a one-time exception and not considering the latter a breaking API change or worthy of a minor version increment. In future versions, a change of this nature will likely be deemed as much.
    Source code(tar.gz)
    Source code(zip)
  • 1.0.0(Jun 6, 2021)

    v1.0 Release 🎉

    • Includes support for all 269nice — Apple-supported flag emojis.
    • Fully-documented internal and external API (w/ Xcode code-completion hints, of course)
    • Swift Package Manager support
    • 92.3% unit-test coverage
    Source code(tar.gz)
    Source code(zip)
Owner
Arnold Rozon
Arnold Rozon
Scanner for decks of cards with bar codes printed on card edges

The Nettle Magic Project This deck of cards has a bar code printed on the edge of each card. Scanning these bar codes would reveal where every card is

Paul Nettle 793 Dec 14, 2022
Style Art library process images using COREML with a set of pre trained machine learning models and convert them to Art style.

StyleArt Style Art is a library that process images using COREML with a set of pre trained machine learning models and convert them to Art style. Prev

iLeaf Solutions Pvt. Ltd. 222 Dec 17, 2022
Convert HEIC images to JPEG format on the Mac

heic2jpeg Convert HEIC images to JPEG format on the Mac A basic tool to convert Apple's obnoxious HEIC format images (as the default photo format for

Fazal Majid 2 Mar 1, 2022
Convert the image to hexadecimal to send the image to e-paper

ConvertImageToHex Convert the image to hexadecimal to send the image to e-paper Conversion Order // 0. hex로 변환할 이미지 var image = UIImage(named: "sample

Hankyeol Park 0 Feb 26, 2022
Convert UIImage to ASCII art

BKAsciiImage As seen on Cmd.fm iOS App https://itunes.apple.com/app/cmd.fm-radio-for-geeks-hackers/id935765356 Installation BKAsciiImage is available

Barış Koç 427 Dec 17, 2022
A tool support convert image gif to gif3d

Trick convert gif to gif3d using Swift Features Simple way to convert gif to gif3d Change background Change size eraser tool How to work Add a layer w

Chuong Tran 16 Jan 4, 2023
A Swift package to convert a colour to a name using Wikipedia's colour list

ColorName Usage import ColorName SwiftUI let myColorName = getName(for: Color.red) print(myColorName) UIKit let myColorName = getName(for: UIColor.red

Jia Chen 3 Aug 9, 2022
Rudimentary implementation of a uncompressed PNG encoder in Swift without any dependencies

MicroPNG This package currently offers a very minimal PNG encoder for uncompressed RGB and RGBA PNG files. It does not rely on any frameworks and shou

Robert Bruinier 2 Sep 11, 2021
Small color quantizer for bitmaps without any dependencies or use of frameworks

MicroColorQuantizer This package currently offers a very simple color quantizer

Robert Bruinier 0 Dec 29, 2021
SwiftColorArt is a demo application that includes Swift files with all classes and extension necessary to create a font color schema matching to an image

SwiftColorArt SwiftColorArt is a demo application that includes Swift files with all classes and extension necessary to create a font color schema mat

Jan Gregor Triebel 264 Jan 4, 2023