Swiftpack.co -  mobven/CountryPicker as Swift Package
Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
Country Picker with unicode flags and country codes.
.package(url: "https://github.com/mobven/CountryPicker.git", from: "1.0.0")


Very simple country picker for iOS with elegant design. It uses unicode for country flags.




  • iOS 13+
  • Xcode 12+
  • Swift 5.3+


Currently CountryPicker is only avaliable via SPM. You can also add manually to your project.


If you have already Swift package set up, add CountryPicker as a dependency to your dependencies in your Package.swift file.

dependencies: [
    .package(url: "https://github.com/mobven/CountryPicker.git")


Simply, you can use with presenting CountryPickerViewController instance in your UIViewController . You can alse set default country for the picker with selectedCountry variable (Default value is "TR"). For use delegate method you should conform to CountryPickerDelegate in your UIViewController.

let countryPicker = CountryPickerViewController()
countryPicker.selectedCountry = "TR"
countryPicker.delegate = self
self.present(countryPicker, animated: true)


Delegate method will be called with country selection, you can update your outlets with new selected country model.

extension ViewController: CountryPickerDelegate {
    func countryPicker(didSelect country: Country) {
        countryTextField.text = country.isoCode.getFlag() + " " + country.localizedName


Default picker theme is supporting Dark Mode for iO13+ devices. You can easly customize the picker with editing Configuration properties. If you are adding custom colors, you should add dark appearance color for dark mode support.

public protocol Configuration {
    var countryNameTextColor: UIColor { get set }
    var countryNameTextFont: UIFont { get set }
    var selectedCountryCodeBackgroundColor: UIColor { get set }
    var selectedCountryCodeTextColor: UIColor { get set }
    var selectedCountryCodeCornerRadius: CGFloat { get set }
    var countryCodeFont: UIFont { get set }
    var countryCodeTextColor: UIColor { get set }
    var closeButtonTextColor: UIColor { get set }
    var closeButtonFont: UIFont { get set }
    var closeButtonText: String { get set }
    var titleTextColor: UIColor { get set }
    var titleFont: UIFont { get set }
    var titleText: String { get set }
    var searchBarPlaceholder: String { get set }
    var searchBarBackgroundColor: UIColor { get set }
    var searchBarPlaceholderColor: UIColor { get set }
    var searchBarFont: UIFont { get set }
    var searchBarLeftImage: UIImage? { get set }
    var searchBarClearImage: UIImage? { get set }
    var searchBarCornerRadius: CGFloat { get set }
    var separatorColor: UIColor { get set }

You can customize properties like this,

  CountryManager.shared.config.countryNameTextColor = .black
  CountryManager.shared.config.countryNameTextFont = UIFont.systemFont(ofSize: 16)

or you can create your own Config

  let configMaker = Config(
      countryNameTextColor: .black,
      countryNameTextFont: UIFont.systemFont(ofSize: 16),
      selectedCountryCodeBackgroundColor: .green

  CountryManager.shared.config = configMaker()

Custom UI

getCountries() method in CountryManager will return a Country array for you, so you can create your own custom UI implementations with this array.

  let countries = CountryManager.shared.getCountries()


CountryPicker uses unicode for country flags. You can use with iso codes like the example below.

  label.text = "US".getFlag()


CountryPicker is use current NSLocale for localization of country name, you can set custom locale before presenting picker.

  CountryManager.shared.localeIdentifier = "en_US"
  let countryPicker = CountryPickerViewController()
  self.present(countryPicker, animated: true)

For page title and close button text you can set localized text with Configration properties

  CountryManager.shared.config.titleText = "Country Picker"
  CountryManager.shared.config.closeButtonText = "Close"

CountryPicker v1.0.0 is support RTL except displaying localized phone codes.

What's next

  • ☐ Sample Project.
  • ☐ SwiftUI representable code example.
  • ☐ Support below iOS 13.

Developed with 🖤 at Mobven


Stars: 6
Last commit: 4 weeks ago

Ad: Job Offers

iOS Software Engineer @ Perry Street Software
Perry Street Software is Jack’d and SCRUFF. We are two of the world’s largest gay, bi, trans and queer social dating apps on iOS and Android. Our brands reach more than 20 million members worldwide so members can connect, meet and express themselves on a platform that prioritizes privacy and security. We invest heavily into SwiftUI and using Swift Packages to modularize the codebase.

Release Notes

5 weeks ago

Initial release

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