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.1.3
Convert Countries, Country Codes, Continents,... with a single line of code.
⭐️ 1
🕓 1 year ago
iOS macOS tvOS
.package(url: "https://github.com/NVMNovem/NVMRegion_swift.git", from: "1.1.3")

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_swift", 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 next function 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: 1 year ago
Advertisement: IndiePitcher.com - Cold Email Software for Startups

Release Notes

1.1.3
1 year ago

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