PhoneNumberKit
A Swift framework for parsing and formatting phone numbers
Swift 5.3 framework for parsing, formatting and validating international phone numbers. Inspired by Google's libphonenumber. Import PhoneNumberKit at the top of the Swift file that will interact with a phone number. All of your interactions with PhoneNumberKit happen through a PhoneNumberKit object. The first step you should take is to allocate one. A PhoneNumberKit instance is relatively expensive to allocate (it parses the metadata and keeps it in memory for the object's lifecycle), you should try and make sure PhoneNumberKit is allocated once and deallocated when no longer needed. To parse a string, use the parse function. The region code is automatically computed but can be overridden if needed. PhoneNumberKit automatically does a hard type validation to ensure that the object created is valid, this can be quite costly performance-wise and can be turned off if needed.