A lightweight Swift Package providing detailed country data with full bilingual support (Arabic + English) — built for SwiftUI and UIKit projects.
Access country names, codes, calling codes, and emoji flags — and search by any attribute — with a clean, offline-first Swift API designed for apps that need first-class Arabic and right-to-left language support.
Most country-data Swift packages are English-only, require network calls, or bundle data inefficiently. CountryCallingCode ships all country data locally with bilingual support (Arabic + English) and a clean search API — designed specifically for apps targeting MENA markets or any product that needs first-class right-to-left language support.
- 🌍 Bilingual country data — names available in both Arabic and English
- 📞 Complete country info — name, ISO country code, international calling code, and emoji flag
- 🔍 Flexible search — find countries by name (Arabic or English), country code, calling code, or flag
- 📦 Zero dependencies — pure Swift, no third-party libraries
✈️ Offline-first — all data bundled in the package; no network calls- 🧩 SwiftUI and UIKit compatible
- Swift 6.0+
- Xcode 16.0+
- iOS 13.0+ recommended
-
In Xcode, go to File → Add Packages…
-
Paste the repository URL:
https://github.com/Mohamed-Mostafa7/CountryCallingCode -
Choose the version (recommended: Up to Next Major Version)
-
Click Add Package
Add CountryCallingCode as a dependency in your Package.swift:
dependencies: [
.package(url: "https://github.com/Mohamed-Mostafa7/CountryCallingCode.git", from: "1.0.0")
]Then add "CountryCallingCode" to your target's dependencies array.
import CountryCallingCode
let provider = CountriesProvider()let allCountries = provider.countries// English
if let results = provider.fetch(name: "Egypt") {
// Returns countries matching "Egypt"
}
// Arabic — returns the same results
if let results = provider.fetch(name: "مصر") {
// Returns Egypt country data
}if let results = provider.fetch(code: "EG") {
// Returns countries matching the code "EG"
}if let results = provider.fetch(callingCode: "+1") {
// Returns countries whose calling code contains "+1"
}if let results = provider.fetch(flag: "🇺🇸") {
// Returns countries matching the flag
}A complete SwiftUI search view using the package:
import SwiftUI
import CountryCallingCode
struct CountrySearchView: View {
@State private var searchQuery = ""
@State private var searchResults: [Country] = []
private let provider = CountriesProvider()
var body: some View {
NavigationView {
VStack {
TextField("Search for a country", text: $searchQuery, onCommit: searchCountries)
.textFieldStyle(.roundedBorder)
.padding()
List(searchResults, id: \.code) { country in
VStack(alignment: .leading, spacing: 4) {
HStack {
Text(country.flag)
Text(country.name.english)
.font(.headline)
}
Text(country.name.arabic)
.font(.subheadline)
.foregroundColor(.secondary)
Text("Code: \(country.code) · Calling: \(country.callingCode)")
.font(.caption)
}
}
}
.navigationTitle("Country Search")
.onAppear {
searchResults = provider.countries ?? []
}
}
}
private func searchCountries() {
searchResults = []
if let results = provider.fetch(name: searchQuery) {
searchResults.append(contentsOf: results)
}
}
}Contributions are welcome. Open issues for bugs or feature requests, or submit a pull request:
- Fork the repository
- Create a feature branch (
git checkout -b feature/your-feature) - Commit your changes
- Push and open a Pull Request
MIT License. See LICENSE for details.
Mohamed Mostafa Darwish iOS Developer · Egypt
