Skip to content

Latest commit

 

History

17 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

objc-libphonenumber-spm

A fork of iziz/libPhoneNumber-iOS updated to work flawlessly as the Swift Package library. Includes PhoneNumberUtil, ShortNumberUtil, AsYouTypeFormatter but does not include a Geocoder. The package is not extensively tested yet, and test targets are not ported from the original repo.

Whenever needed, pass the metadataHelper explicitly during initialization, otherwise the instance won't initialize propoerly.

final class PhoneUtils {

  private let phoneUtil: NBPhoneNumberUtil
  private let asYouType: NBAsYouTypeFormatter
  private let shortNumberUtil: NBShortNumberUtil
  
  init() {
    let metadataHelper = NBMetadataHelper()!
    let shortNumberMetaDataHelper = NBShortNumberMetadataHelper()
    let phoneUtil = NBPhoneNumberUtil(metadataHelper: metadataHelper)!
    
    self.phoneUtil = phoneUtil
    self.asYouType = .init(regionCode: Locale.current.regionCode)
    self.shortNumberUtil = .init(metadataHelper: shortNumberMetaDataHelper, phoneNumberUtil: phoneUtil)
    }
    
    // wrap the methods you need for your usecases
    //
    //
}

For NBPhoneNumberUtil a shared instance is available that does seem to work properly despite marked as depricated:

private static let phoneLib: NBPhoneNumberUtil! = NBPhoneNumberUtil.sharedInstance()

About Relux Works

This project is part of the open-source ecosystem of Relux Works, an AI-native software development studio. We build fixed-price MVPs, rescue vibe-coded apps, run local AI inference, and train teams to work with coding agents. Much of the infrastructure behind that work is open source.

About

A fork of libPhoneNumber-iOS updated to work flawlessly as the Swift Package library.

Resources

Stars

2 stars

Watchers

3 watching

Forks

Releases

Packages

Contributors

Languages