Home

Awesome

CountryPicker

CountryPicker

Awesome Build Status

<!-- Your project description and other contents below -->

codecov Version Badge

Carthage compatible Swift Package Manager compatible License

CountryPicker is a Swift library that provides a simple and easy-to-use interface for selecting countries from a predefined list. It's perfect for adding country selection functionality to your iOS app with minimal effort.

If you like CountryPicker, give it a ★ at the top right of this page.

Features

Requirements

Demo Project

To run the example project, clone the repo, and run pod update from the Example directory first.

<img src= "Usage Resource/SKCountryPickerDemo.gif" width="200" height = "400">

Swift UI Combine new project

<img src= "Usage Resource/SKCountryPicker15Plus.gif" width="200" height = "400">|

Screenshots

Home SceneCountry Picker SceneFiltering SceneDark Mode ScenePicker View
<img src= "Usage Resource/SKCountryPickerHomeScene.png" width="166" height = "330"><img src= "Usage Resource/SKCountryPickerScene.png" width="166" height = "330"><img src= "Usage Resource/SKCountryPickerFilterScene.png" width="166" height = "330"><img src= "Usage Resource/DarkMode.png" width="166" height = "330"><img src= "Usage Resource/pickerView.png" width="166" height = "330">

Installation

CountryPicker is available through Cocoapods and Carthage.

CocoaPods:

Add the following line to your Podfile:

For iOS 15 and above (Combine and Swiftui version) currently only supported by cocoapods 
pod 'SKCountryPicker'

Please note iOS 15 will be discontinued after in 2024.

Carthage

The steps required to use Carthage for dependency management are described here but lets add them to this README as well for good measure.

First you need to add the following line to your Cartfile

github "SURYAKANTSHARMA/CountryPicker"

to include the latest version of CountryPicker.

(if you don't have a Cartfile, you need to create one first in your favorite texteditor)

Next run

carthage update --platform iOS

This will have Carthage:

once Carthage finishes building, you need to add the framework to your project.

In Xcode:

The final step is to add the copy-frameworks build script to your "Build Phases".

Done!

SPM

Add the following line to your Package.swift file in the dependencies section:

.package(url: "https://github.com/SURYAKANTSHARMA/CountryPicker.git, from "4.0.0")

Getting Started

Please check baseiOS11Example project for customization and different option available for using with old uikit.

Please check baseiOS15Example project for using it in swift ui app with minimum deployment target iOS 15

Filter Options

There are 3 main filter options countryName, countryCode, countryDialCode and by default country picker has been configured to filter countries based on countryName.

If you want to add/remove filter options, do as follows:


 // Adding filter
 CountryManager.shared.addFilter(.countryCode)

 // Removing filter
 CountryManager.shared.removeFilter(.countryCode)

 // Removing all filters
 CountryManager.shared.clearAllFilters()

Incase you want to retrieve country info


// Get country based on digit code e.g: 60, +255
CountryManager.shared.country(withDigitCode: "255")

// Get country based on country name
CountryManager.shared.country(withName: "Tanzania")

// Get country based on country code e.g: MY, TZ
CountryManager.shared.country(withCode: "MY")

Dependency Graph

Dependecy graph

For swift ui

Contributing

Any contribution making project better is welcome.

Authors

*Suryakant Sharma

See also the list of contributors who participated in this project. Thanks from bottom of my heart to inspiration behind <a href="https://github.com/hardeep-singh">Hardeep Singh</a>

License

This project is licensed under the MIT License - see the LICENSE file for details