PhoneNumberKit parses, formats, and validates international phone numbers in Swift using metadata aligned with Google’s libPhoneNumber project. Optional UI components provide as-you-type formatting in text fields.
Overview
PhoneNumberKit exposes a PhoneNumberUtility entry point that loads numbering metadata once and parses strings into immutable PhoneNumber structs with country and national components. Parsing can enforce strict validation or relax checks for bulk imports via a dedicated array parser.
Formatting helpers turn parsed numbers into display styles, and utilities map between region codes and country names. PhoneNumberTextField replaces UITextField for live as-you-type formatting, with optional flag buttons and example placeholders tied to the current region.
The original maintainer line is frozen at 4.3.0; active development moved to the PhoneNumberKit organization split across core and PhoneNumberUI packages, with migration guidance for dependents on the legacy line.
Distribution supports Swift Package Manager, Carthage, and CocoaPods for iOS projects.
Key features
- Parse and validate international numbers
- Format numbers for display styles
- As-you-type PhoneNumberTextField UI
- Country code and name conversion
- Bulk array parsing mode
- libPhoneNumber-derived metadata
- Custom country picker styling
Use cases
- Validate phone fields in iOS registration forms
- Format contact numbers for display
- Build reusable phone entry UI components
- Normalize numbers before server submission