### CocoaPods Installation (Swift 4.1/3.3) Source: https://github.com/suryakantsharma/countrypicker/blob/master/Examples/CoCoaPods/Pods/SKCountryPicker/README.md Use this version specifier if you need compatibility with Swift 4.1 or 3.3. ```ruby pod 'SKCountryPicker' '~> 2.0.0' ``` -------------------------------- ### Install CountryPicker with CocoaPods Source: https://github.com/suryakantsharma/countrypicker/blob/master/README.md Add this line to your Podfile for iOS 15 and above (Combine and SwiftUI version). ```ruby pod 'SKCountryPicker' ``` -------------------------------- ### CocoaPods Installation Source: https://context7.com/suryakantsharma/countrypicker/llms.txt Integrate SKCountryPicker into your iOS project using CocoaPods. Specify the pod name in your Podfile. ```ruby # Podfile pod 'SKCountryPicker' # For Swift 4.1/3.3 support pod 'SKCountryPicker', '~> 2.0.0' ``` -------------------------------- ### Swift Package Manager Installation Source: https://context7.com/suryakantsharma/countrypicker/llms.txt Add the SKCountryPicker library to your project using Swift Package Manager by specifying the repository URL and version. ```swift // Package.swift dependencies: [ .package(url: "https://github.com/SURYAKANTSHARMA/CountryPicker.git", from: "1.2.7") ] ``` -------------------------------- ### Get Country Info by Name Source: https://github.com/suryakantsharma/countrypicker/blob/master/README.md Retrieve country information by providing the full country name (e.g., 'Tanzania'). This method is case-sensitive. ```swift CountryManager.shared.country(withName: "Tanzania") ``` -------------------------------- ### Present CountryPickerView (SwiftUI Flat List) Source: https://context7.com/suryakantsharma/countrypicker/llms.txt Display a searchable flat list of countries using `CountryPickerView`. It auto-dismisses on selection and updates `CountryManager.shared.lastCountrySelected`. This example shows how to present it modally. ```swift import SwiftUI import SKCountryPicker struct PhoneEntryView: View { @State private var selectedCountry: Country? = CountryManager.shared.preferredCountry @State private var isPickerPresented = false var body: some View { VStack(spacing: 20) { Button { isPickerPresented = true } label: { HStack { if let country = selectedCountry { Image(uiImage: country.flag ?? UIImage()) .resizable() .frame(width: 32, height: 22) .cornerRadius(4) Text(country.dialingCode ?? "") Text(country.countryName) } else { Text("Select country") } } .padding() .overlay(RoundedRectangle(cornerRadius: 8).stroke()) } } .sheet(isPresented: $isPickerPresented) { CountryPickerView( configuration: Configuration( flagStyle: .corner, isCountryDialHidden: false ), selectedCountry: $selectedCountry ) } } } ``` -------------------------------- ### Get Country Info by Country Code Source: https://github.com/suryakantsharma/countrypicker/blob/master/README.md Retrieve country information using its standard two-letter country code (e.g., 'MY' for Malaysia). ```swift CountryManager.shared.country(withCode: "MY") ``` -------------------------------- ### Get All Countries with Favorites Source: https://context7.com/suryakantsharma/countrypicker/llms.txt Retrieve a sorted list of all countries, with specified favorite country codes appearing at the beginning of the list. The remaining countries are sorted alphabetically by name. ```swift import SKCountryPicker // Returns full country list sorted by name, with favorites prepended let countries = CountryManager.shared.allCountries(["IN", "US"]) // countries[0].countryCode == "IN" (favourite) // countries[1].countryCode == "US" (favourite) // countries[2...] sorted alphabetically ``` -------------------------------- ### Retrieve Country Information Source: https://github.com/suryakantsharma/countrypicker/blob/master/Examples/CoCoaPods/Pods/SKCountryPicker/README.md Get country details using various identifiers. Supports retrieval by digit code, country name, or country code. ```swift // 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") ``` -------------------------------- ### Present CountryPickerWithSections (SwiftUI Sectioned List) Source: https://context7.com/suryakantsharma/countrypicker/llms.txt Use `CountryPickerWithSections` for a sectioned list of countries with a side index, similar to iOS Contacts. This example demonstrates presenting it modally and configuring its appearance. ```swift import SwiftUI import SKCountryPicker struct RegistrationView: View { @State private var selectedCountry: Country? = CountryManager.shared.preferredCountry @State private var isPickerPresented = false var body: some View { VStack { Button("Choose Country") { isPickerPresented = true } if let country = selectedCountry { HStack { Image(uiImage: country.flag ?? UIImage()) .resizable() .clipShape(Circle()) .frame(width: 40, height: 40) VStack(alignment: .leading) { Text(country.countryName).font(.headline) Text(country.dialingCode ?? "").font(.subheadline).foregroundColor(.secondary) } } .padding() } } .sheet(isPresented: $isPickerPresented) { // "IN" and "US" appear as favourite (unpinned section) at the top CountryPickerWithSections( configuration: Configuration( flagStyle: .circular, navigationTitleText: "Select Your Country" ), selectedCountry: $selectedCountry ) // Note: favoriteCountriesLocaleIdentifiers is configured via the ViewModel // when using CountryPickerSectionViewModel directly } } } ``` -------------------------------- ### Custom Picker View with Section ViewModel (SwiftUI) Source: https://context7.com/suryakantsharma/countrypicker/llms.txt Utilize CountryPickerWithSectionViewModel for programmatic control over country sections, favorites, and search. This example shows integration with a TextField for searching and a List for display. ```swift import SwiftUI import SKCountryPicker struct CustomPickerView: View { @StateObject private var viewModel = CountryPickerWithSectionViewModel( selectedCountry: Country(countryCode: "IN") ) @State private var searchText = "" @Binding var selectedCountry: Country? var body: some View { VStack { TextField("Search countries...", text: $searchText) .textFieldStyle(.roundedBorder) .padding() .onChange(of: searchText) { text in viewModel.filterWithText(text) } List { ForEach(viewModel.sections) { section in Section(header: section.title.map { Text($0) }) { ForEach(section.countries) { country in HStack { Image(uiImage: country.flag ?? UIImage()) .resizable() .frame(width: 32, height: 22) Text(country.countryName) Spacer() Text(country.dialingCode ?? "") .foregroundColor(.secondary) } .onTapGesture { selectedCountry = country viewModel.setLastSelectedCountry() } } } } } } .onChange(of: viewModel.selectedCountry) { newCountry in selectedCountry = newCountry } } } ``` -------------------------------- ### Get Country Info by Digit Code Source: https://github.com/suryakantsharma/countrypicker/blob/master/README.md Retrieve country information using its digit code (e.g., '255' for Tanzania). This is useful when you have the numerical part of a phone number's country code. ```swift CountryManager.shared.country(withDigitCode: "255") ``` -------------------------------- ### Get Current Device Locale Country Source: https://context7.com/suryakantsharma/countrypicker/llms.txt Retrieve the Country object that matches the device's current locale or region using the shared CountryManager instance. Also demonstrates accessing the preferred country, which prioritizes the last selected country. ```swift import SKCountryPicker // Returns the Country matching the device's current locale/region if let current = CountryManager.shared.currentCountry { print(current.countryName) // e.g. "United States" print(current.dialingCode ?? "") // e.g. "+1" } // preferredCountry returns lastCountrySelected if available, otherwise currentCountry let preferred = CountryManager.shared.preferredCountry ``` -------------------------------- ### Update Carthage dependencies Source: https://github.com/suryakantsharma/countrypicker/blob/master/README.md Run this command after adding the dependency to your Cartfile to fetch and compile the framework. ```bash carthage update --platform iOS ``` -------------------------------- ### Add Carthage framework to Xcode project Source: https://github.com/suryakantsharma/countrypicker/blob/master/README.md This script is necessary to ensure the framework is copied correctly during the build process. ```bash /usr/local/bin/carthage copy-frameworks ``` -------------------------------- ### Country Model Initialization and Properties Source: https://context7.com/suryakantsharma/countrypicker/llms.txt Demonstrates how to initialize a Country object using its country code and access its properties like name, dialing code, and flag. ```APIDOC ## Country Model `Country` is the core data model representing a single country. It is `Identifiable`, `Equatable`, and `Hashable`, making it suitable for use in SwiftUI `List` and `ForEach` views. ```swift import SKCountryPicker // Initialize a country directly by ISO 3166-1 alpha-2 code let india = Country(countryCode: "IN") print(india.countryCode) // "IN" print(india.countryName) // "India" (localized to device language) print(india.dialingCode ?? "") // "+91" print(india.digitCountrycode ?? "") // "91" // Access the flag UIImage for display if let flag = india.flag { // use flag in UIImageView or SwiftUI Image(uiImage:) } // Localized name in a specific locale let name = india.countryName(withLocaleIdentifier: "fr") // "Inde" // Equality check is based on countryCode + dialingCode let also_india = Country(countryCode: "IN") print(india == also_india) // true ``` ``` -------------------------------- ### Configure Visual Appearance of Country Picker Views Source: https://context7.com/suryakantsharma/countrypicker/llms.txt Customize the visual elements of country picker views using the `Configuration` struct. This includes flag style, fonts, colors, and visibility of country details. Pass this configuration to any picker view. ```swift import SKCountryPicker import SwiftUI let config = Configuration( flagStyle: .circular, // .normal | .corner | .circular labelFont: .body, labelColor: .primary, detailFont: .caption, detailColor: .secondary, isCountryFlagHidden: false, // hide flag images isCountryDialHidden: false, // hide dialing code text navigationTitleText: "Select Country", accessibilityConfiguration: AccessibilityConfiguration( enableVoiceOverAnnouncements: true ) ) // Pass to any picker view CountryPickerView(configuration: config, selectedCountry: $selectedCountry) ``` -------------------------------- ### Add CountryPicker dependency with Carthage Source: https://github.com/suryakantsharma/countrypicker/blob/master/README.md Add this line to your Cartfile to include the latest version of CountryPicker. ```bash github "SURYAKANTSHARMA/CountryPicker" ``` -------------------------------- ### Configure Accessibility for VoiceOver (Swift) Source: https://context7.com/suryakantsharma/countrypicker/llms.txt Customize VoiceOver announcements for country selection and search results using AccessibilityConfiguration. Set enableVoiceOverAnnouncements to false to disable. ```swift import SKCountryPicker // Enable VoiceOver announcements (default: true) let a11yConfig = AccessibilityConfiguration(enableVoiceOverAnnouncements: true) let config = Configuration( flagStyle: .corner, navigationTitleText: "Select Country", accessibilityConfiguration: a11yConfig ) // When enableVoiceOverAnnouncements = true: // - Selecting a country announces: "Selected {countryName}" // - Typing in search announces: "Found N countries matching '{query}'" // - Clearing search announces: "Showing all countries" // To disable announcements: let silentConfig = Configuration( accessibilityConfiguration: AccessibilityConfiguration( enableVoiceOverAnnouncements: false ) ) ``` -------------------------------- ### Country Model Initialization and Properties Source: https://context7.com/suryakantsharma/countrypicker/llms.txt Initialize a Country object using its ISO 3166-1 alpha-2 code. Access properties like country code, localized name, dialing code, and flag image. Equality checks are based on countryCode and dialingCode. ```swift import SKCountryPicker // Initialize a country directly by ISO 3166-1 alpha-2 code let india = Country(countryCode: "IN") print(india.countryCode) // "IN" print(india.countryName) // "India" (localized to device language) print(india.dialingCode ?? "") // "+91" print(india.digitCountrycode ?? "") // "91" // Access the flag UIImage for display if let flag = india.flag { // use flag in UIImageView or SwiftUI Image(uiImage:) } // Localized name in a specific locale let name = india.countryName(withLocaleIdentifier: "fr") // "Inde" // Equality check is based on countryCode + dialingCode let also_india = Country(countryCode: "IN") print(india == also_india) // true ``` -------------------------------- ### Configure Styling Options for Country Picker Source: https://github.com/suryakantsharma/countrypicker/blob/master/Examples/CoCoaPods/Pods/SKCountryPicker/README.md Customize the appearance of the country picker, including flag style, and visibility of the flag and dialing code. ```swift CountryPickerWithSectionViewController.presentController(on: self, configuration: { controller in // Styling country flag image view controller.configuration.flagStyle = .circular // Hide flag image view controller.configuration.isCountryFlagHidden = true // Hide country dial code controller.configuration.isCountryDialHidden = true }) ``` -------------------------------- ### CountryManager.shared.allCountries(_:) Source: https://context7.com/suryakantsharma/countrypicker/llms.txt Retrieves a list of all countries, with specified favorite country codes appearing at the beginning of the list, followed by the rest sorted alphabetically. ```APIDOC ### `allCountries(_:)` — Full List with Favorites ```swift import SKCountryPicker // Returns full country list sorted by name, with favorites prepended let countries = CountryManager.shared.allCountries(["IN", "US"]) // countries[0].countryCode == "IN" (favourite) // countries[1].countryCode == "US" (favourite) // countries[2...] sorted alphabetically ``` ``` -------------------------------- ### Look Up Country by ISO Code Source: https://context7.com/suryakantsharma/countrypicker/llms.txt Find a Country object by its ISO 3166-1 alpha-2 code using the CountryManager. The lookup is case-insensitive. ```swift import SKCountryPicker if let country = CountryManager.shared.country(withCode: "MY") { print(country.countryName) // "Malaysia" print(country.dialingCode ?? "") // "+60" } // Case-insensitive let us = CountryManager.shared.country(withCode: "us") // works ``` -------------------------------- ### Present Country Picker with Section Control Source: https://github.com/suryakantsharma/countrypicker/blob/master/Examples/CoCoaPods/Pods/SKCountryPicker/README.md Presents the country picker with the section control enabled. Customize flag style, visibility of flag and dialing code, and set favorite countries. ```swift func presentCountryPickerScene(withSelectionControlEnabled selectionControlEnabled: Bool = true) { switch selectionControlEnabled { case true: // Present country picker with `Section Control` enabled CountryPickerWithSectionViewController.presentController(on: self, configuration: { countryController in countryController.configuration.flagStyle = .circular countryController.configuration.isCountryFlagHidden = !showCountryFlagSwitch.isOn countryController.configuration.isCountryDialHidden = !showDialingCodeSwitch.isOn countryController.favoriteCountriesLocaleIdentifiers = ["IN", "US"] }) { [weak self] country in guard let self = self else { return } self.countryImageView.isHidden = false self.countryImageView.image = country.flag self.countryCodeButton.setTitle(country.dialingCode, for: .normal) } case false: // Present country picker without `Section Control` enabled CountryPickerController.presentController(on: self, configuration: { countryController in countryController.configuration.flagStyle = .corner countryController.configuration.isCountryFlagHidden = !showCountryFlagSwitch.isOn countryController.configuration.isCountryDialHidden = !showDialingCodeSwitch.isOn countryController.favoriteCountriesLocaleIdentifiers = ["IN", "US"] }) { [weak self] country in guard let self = self else { return } self.countryImageView.isHidden = false self.countryImageView.image = country.flag self.countryCodeButton.setTitle(country.dialingCode, for: .normal) } } } } ``` -------------------------------- ### Add CountryPicker Dependency to Package.swift Source: https://github.com/suryakantsharma/countrypicker/blob/master/README.md Add this line to your Package.swift file's dependencies section to include the CountryPicker library. ```swift .package(url: "https://github.com/SURYAKANTSHARMA/CountryPicker.git, from "4.0.0") ``` -------------------------------- ### SPM Dependency Source: https://github.com/suryakantsharma/countrypicker/blob/master/Examples/CoCoaPods/Pods/SKCountryPicker/README.md Add this line to the dependencies section of your Package.swift file to integrate CountryPicker using Swift Package Manager. ```swift .package(url: "https://github.com/SURYAKANTSHARMA/CountryPicker.git, from "1.2.7") ``` -------------------------------- ### CountryManager.shared.country(withCode:) Source: https://context7.com/suryakantsharma/countrypicker/llms.txt Looks up and returns a Country object based on its ISO 3166-1 alpha-2 country code. The lookup is case-insensitive. ```APIDOC ### `country(withCode:)` — Look Up by ISO Code ```swift import SKCountryPicker if let country = CountryManager.shared.country(withCode: "MY") { print(country.countryName) // "Malaysia" print(country.dialingCode ?? "") // "+60" } // Case-insensitive let us = CountryManager.shared.country(withCode: "us") // works ``` ``` -------------------------------- ### Look Up Country by Name Source: https://context7.com/suryakantsharma/countrypicker/llms.txt Retrieve a Country object by its name using the CountryManager. This method searches for the country name. ```swift import SKCountryPicker if let country = CountryManager.shared.country(withName: "Tanzania") { print(country.countryCode) // "TZ" print(country.digitCountrycode ?? "") // "255" } ``` -------------------------------- ### Add, Remove, and Clear Country Filters Source: https://github.com/suryakantsharma/countrypicker/blob/master/Examples/CoCoaPods/Pods/SKCountryPicker/README.md Manage filter options for the country picker. Add filters for country code, remove specific filters, or clear all filters. ```swift // Adding filter CountryManager.shared.addFilter(.countryCode) // Removing filter CountryManager.shared.removeFilter(.countryCode) // Removing all filters CountryManager.shared.clearAllFilters() ``` -------------------------------- ### Filter Countries by Search Text Source: https://context7.com/suryakantsharma/countrypicker/llms.txt Search for countries using the CountryManager. By default, filters by country name. Additional filters for country code and dial code can be enabled. ```swift import SKCountryPicker // Default filter is by countryName let results = CountryManager.shared.filterCountries(searchText: "Ind") // Returns [India, Indonesia, ...] // Filter by multiple criteria CountryManager.shared.addFilter(.countryCode) CountryManager.shared.addFilter(.countryDialCode) let byCode = CountryManager.shared.filterCountries(searchText: "IN") // Now matches on name, ISO code, and dial code ``` -------------------------------- ### SwiftUI Phone Number Entry Form with Country Picker Source: https://context7.com/suryakantsharma/countrypicker/llms.txt This SwiftUI view combines country selection with phone number input. Configure filters on appear and present the country picker as a sheet. The selected country's flag and dial code are displayed. ```swift import SwiftUI import SKCountryPicker struct PhoneNumberForm: View { @State private var selectedCountry: Country = CountryManager.shared.preferredCountry ?? Country(countryCode: "US") @State private var phoneNumber = "" @State private var showPicker = false // Configure filters once on appear private func configureFilters() { CountryManager.shared.addFilter(.countryCode) CountryManager.shared.addFilter(.countryDialCode) } var body: some View { Form { Section("Phone Number") { HStack { // Country selector button Button { showPicker = true } label: { HStack(spacing: 6) { Image(uiImage: selectedCountry.flag ?? UIImage()) .resizable() .clipShape(Circle()) .frame(width: 28, height: 28) Text(selectedCountry.dialingCode ?? "+?") .foregroundColor(.primary) Image(systemName: "chevron.down") .font(.caption) .foregroundColor(.secondary) } } Divider() TextField("Enter number", text: $phoneNumber) .keyboardType(.phonePad) } } Section { VStack(alignment: .leading, spacing: 4) { Text("Country: \(selectedCountry.countryName)") Text("ISO Code: \(selectedCountry.countryCode)") Text("Dial Code: \(selectedCountry.dialingCode ?? "N/A")") } .font(.footnote) .foregroundColor(.secondary) } } .navigationTitle("Contact Info") .onAppear { configureFilters() } .sheet(isPresented: $showPicker) { CountryPickerWithSections( configuration: Configuration( flagStyle: .circular, isCountryDialHidden: false, navigationTitleText: "Select Country" ), selectedCountry: Binding( get: { selectedCountry }, set: { if let c = $0 { selectedCountry = c } } ) ) } } } ``` -------------------------------- ### Add Filter Option to CountryPicker Source: https://github.com/suryakantsharma/countrypicker/blob/master/README.md Use this method to add a filter option, such as country code, to the CountryManager. Ensure CountryManager is initialized before use. ```swift CountryManager.shared.addFilter(.countryCode) ``` -------------------------------- ### CountryManager.shared.country(withName:) Source: https://context7.com/suryakantsharma/countrypicker/llms.txt Searches for and returns a Country object based on its name. This method is useful for finding a country when only its name is known. ```APIDOC ### `country(withName:)` — Look Up by Name ```swift import SKCountryPicker if let country = CountryManager.shared.country(withName: "Tanzania") { print(country.countryCode) // "TZ" print(country.digitCountrycode ?? "") // "255" } ``` ``` -------------------------------- ### Look Up Country by Dial Code Source: https://context7.com/suryakantsharma/countrypicker/llms.txt Find a Country object using its international dialing code. The lookup supports codes with or without a leading '+'. ```swift import SKCountryPicker // Works with or without a leading "+" let byPlus = CountryManager.shared.country(withDigitCode: "+255") // Tanzania let byDigits = CountryManager.shared.country(withDigitCode: "255") // Tanzania if let country = byPlus { print(country.countryName) // "Tanzania" print(country.countryCode) // "TZ" } ``` -------------------------------- ### Manage Country Search Filters with CountryManager Source: https://context7.com/suryakantsharma/countrypicker/llms.txt Add, remove, or clear search filters for country matching. Filters are managed using a Set, preventing duplicates. Available filters include country name, ISO code, and dial code. ```swift import SKCountryPicker // Add a filter (no duplicates — backed by a Set) CountryManager.shared.addFilter(.countryCode) CountryManager.shared.addFilter(.countryDialCode) // Remove a single filter CountryManager.shared.removeFilter(.countryCode) // Reset to default (.countryName only) CountryManager.shared.clearAllFilters() // Available cases: // .countryName — matches on full/partial country name // .countryCode — matches on ISO alpha-2 code (e.g. "US", "IN") // .countryDialCode — matches on numeric dial code (e.g. "91", "1") ``` -------------------------------- ### Inline Country Picker Wheel View (SwiftUI) Source: https://context7.com/suryakantsharma/countrypicker/llms.txt Use CountryPickerWheelView for an inline, scrollable drum-roll country selector. It requires a non-optional binding for the selected country. ```swift import SwiftUI import SKCountryPicker struct InlineCountryPickerView: View { // Wheel picker requires a non-optional binding @State private var selectedCountry: Country = CountryManager.shared.preferredCountry ?? Country(countryCode: "US") var body: some View { VStack(spacing: 16) { // Live selection display HStack { Image(uiImage: selectedCountry.flag ?? UIImage()) .resizable() .scaledToFit() .frame(width: 40, height: 25) Text(selectedCountry.countryName) .font(.title2) Spacer() Text(selectedCountry.dialingCode ?? "") .foregroundColor(.secondary) } .padding(.horizontal) Divider() // Inline wheel picker — no sheet required CountryPickerWheelView(selectedCountry: $selectedCountry) } } } // With a custom data source / ViewModel struct CustomWheelPickerView: View { @State private var selectedCountry: Country = Country(countryCode: "IN") @StateObject private var viewModel = CountryPickerWheelViewModel() var body: some View { CountryPickerWheelView( selectedCountry: $selectedCountry, viewModel: viewModel ) } } ``` -------------------------------- ### CountryManager.shared.country(withDigitCode:) Source: https://context7.com/suryakantsharma/countrypicker/llms.txt Finds a Country object using its international dialing code. The search supports codes with or without a leading '+' sign. ```APIDOC ### `country(withDigitCode:)` — Look Up by Dial Code ```swift import SKCountryPicker // Works with or without a leading "+" let byPlus = CountryManager.shared.country(withDigitCode: "+255") // Tanzania let byDigits = CountryManager.shared.country(withDigitCode: "255") // Tanzania if let country = byPlus { print(country.countryName) // "Tanzania" print(country.countryCode) // "TZ" } ``` ``` -------------------------------- ### CountryManager.shared.filterCountries(searchText:) Source: https://context7.com/suryakantsharma/countrypicker/llms.txt Filters the list of countries based on a search text. By default, it filters by country name, but can be configured to include filtering by country code and dial code. ```APIDOC ### `filterCountries(searchText:)` — Search ```swift import SKCountryPicker // Default filter is by countryName let results = CountryManager.shared.filterCountries(searchText: "Ind") // Returns [India, Indonesia, ...] // Filter by multiple criteria CountryManager.shared.addFilter(.countryCode) CountryManager.shared.addFilter(.countryDialCode) let byCode = CountryManager.shared.filterCountries(searchText: "IN") // Now matches on name, ISO code, and dial code ``` ``` -------------------------------- ### CountryManager.shared.currentCountry Source: https://context7.com/suryakantsharma/countrypicker/llms.txt Retrieves the country object that matches the device's current locale or region. ```APIDOC ### `currentCountry` — Device Locale Country ```swift import SKCountryPicker // Returns the Country matching the device's current locale/region if let current = CountryManager.shared.currentCountry { print(current.countryName) // e.g. "United States" print(current.dialingCode ?? "") // e.g. "+1" } // preferredCountry returns lastCountrySelected if available, otherwise currentCountry let preferred = CountryManager.shared.preferredCountry ``` ``` -------------------------------- ### Clear All Filters in CountryPicker Source: https://github.com/suryakantsharma/countrypicker/blob/master/README.md This function removes all currently active filters from the CountryManager, resetting it to its default state. ```swift CountryManager.shared.clearAllFilters() ``` -------------------------------- ### Remove Filter Option from CountryPicker Source: https://github.com/suryakantsharma/countrypicker/blob/master/README.md Use this method to remove a specific filter option, like country code, from the CountryManager. ```swift CountryManager.shared.removeFilter(.countryCode) ``` -------------------------------- ### Reset Last Selected Country State (Swift) Source: https://context7.com/suryakantsharma/countrypicker/llms.txt Clear the stored last-selected country using CountryManager.shared.resetLastSelectedCountry(). After resetting, preferredCountry will fall back to the device's current locale. ```swift import SKCountryPicker // Clear the stored last-selected country (e.g. on logout or account switch) CountryManager.shared.resetLastSelectedCountry() // After reset, preferredCountry falls back to currentCountry (device locale) let fallback = CountryManager.shared.preferredCountry print(fallback?.countryName ?? "No locale detected") ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.