Swiftpack.co - NVMNovem/NVMRegion_swift as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by NVMNovem.
NVMNovem/NVMRegion_swift 1.0.5
Convert Countries, Country Codes, Continents,... with a single line of code.
⭐️ 1
🕓 2 weeks ago
iOS macOS
.package(url: "https://github.com/NVMNovem/NVMRegion_swift.git", from: "1.0.5")

NVMRegion_header

iOS · macOS · watchOS · tvOS


A pure Swift library that allows you to easily convert Countries to Country Codes and Country Codes to Countries.

There is also support for other types. Currently all supported types are Countries, Alpha2Codes, Alpha3Codes and Numerics.

This project is created and maintained by Novem.


Installation

Swift Package Manager

You can use The Swift Package Manager (SPM) to install NVMRegion by adding the following description to your Package.swift file:

import PackageDescription

let package = Package(
    name: "YOUR_PROJECT_NAME",
    dependencies: [
        .package(url: "https://github.com/NVMNovem/NVMRegion", from: "1.0.0"),
    ]
)

Then run swift build.

You can also install using SPM in your Xcode project by going to "Project->NameOfYourProject->Swift Packages" and placing "https://github.com/NVMNovem/NVMRegion" in the search field. Then select the option that is most suited for your needs.

Usage Guide

Code

To use NVMRegion, there is no initalizing required. If you want to add custom Country Aliases, you need to add the in the initalizing of your app. Example use case for a custom country name for Belgium. The example will allow the translated version "België" to be converted to a Country: "Belgium".

@main
struct MyApp: App {    
    init() {
        NVMRegion.implementCountryAliases(["België" : .Belgium])
    }
    
    var body: some Scene {
        WindowGroup {
            ContentView()
        }
    }
}

This will make it possible to create a Country() object from "België". This is not required for default country names. NVMRegion also tries to find the most fitted country for each given string.

Country("België")

This will return a valid Country() object

(
Belgium
Continent: Europe
Alpha2 Code: BE
Alpha3 Code: BEL
Numeric: N056
)

GitHub

link
Stars: 1
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Release Notes

1.0.5
2 weeks ago

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics