From 9fc5e71be15123d7b7be48bfd12ab9135c0430db Mon Sep 17 00:00:00 2001 From: Roy Marmelstein Date: Thu, 11 Feb 2016 22:45:30 +0100 Subject: [PATCH] Release 0.6 --- PhoneNumberKit.podspec | 2 +- PhoneNumberKit.xcodeproj/project.pbxproj | 8 ++++---- PhoneNumberKit/Info.plist | 4 ++-- PhoneNumberKit/PartialFormatter.swift | 7 ++++++- PhoneNumberKitTests/Info.plist | 4 ++-- PhoneNumberKitTests/PartialFormatterTests.swift | 3 +-- README.md | 13 +++++++++++-- examples/AsYouType/Sample/ViewController.swift | 2 ++ 8 files changed, 29 insertions(+), 14 deletions(-) diff --git a/PhoneNumberKit.podspec b/PhoneNumberKit.podspec index 8257bc786..db50dbf4c 100644 --- a/PhoneNumberKit.podspec +++ b/PhoneNumberKit.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = "PhoneNumberKit" - s.version = "0.3" + s.version = "0.6" s.summary = "Swift framework for working with phone numbers" # This description is used to generate tags and improve search results. diff --git a/PhoneNumberKit.xcodeproj/project.pbxproj b/PhoneNumberKit.xcodeproj/project.pbxproj index d6952045d..179bcd23c 100644 --- a/PhoneNumberKit.xcodeproj/project.pbxproj +++ b/PhoneNumberKit.xcodeproj/project.pbxproj @@ -321,7 +321,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 11; + CURRENT_PROJECT_VERSION = 12; DEBUG_INFORMATION_FORMAT = dwarf; ENABLE_STRICT_OBJC_MSGSEND = YES; ENABLE_TESTABILITY = YES; @@ -371,7 +371,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; COPY_PHASE_STRIP = NO; - CURRENT_PROJECT_VERSION = 11; + CURRENT_PROJECT_VERSION = 12; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; ENABLE_NS_ASSERTIONS = NO; ENABLE_STRICT_OBJC_MSGSEND = YES; @@ -401,7 +401,7 @@ CLANG_ENABLE_MODULES = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 11; + DYLIB_CURRENT_VERSION = 12; DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = PhoneNumberKit/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; @@ -420,7 +420,7 @@ CLANG_ENABLE_MODULES = YES; DEFINES_MODULE = YES; DYLIB_COMPATIBILITY_VERSION = 1; - DYLIB_CURRENT_VERSION = 11; + DYLIB_CURRENT_VERSION = 12; DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = PhoneNumberKit/Info.plist; INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks"; diff --git a/PhoneNumberKit/Info.plist b/PhoneNumberKit/Info.plist index 72446b949..37a421361 100644 --- a/PhoneNumberKit/Info.plist +++ b/PhoneNumberKit/Info.plist @@ -15,11 +15,11 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 0.3 + 0.6 CFBundleSignature ???? CFBundleVersion - 11 + 12 NSPrincipalClass diff --git a/PhoneNumberKit/PartialFormatter.swift b/PhoneNumberKit/PartialFormatter.swift index 1e74f445d..c9f006220 100644 --- a/PhoneNumberKit/PartialFormatter.swift +++ b/PhoneNumberKit/PartialFormatter.swift @@ -24,7 +24,12 @@ public class PartialFormatter { //MARK: Lifecycle - convenience init() { + /** + Initialise a partial formatter with the default region + + - returns: PartialFormatter object + */ + public convenience init() { let region = PhoneNumberKit().defaultRegionCode() self.init(region: region) } diff --git a/PhoneNumberKitTests/Info.plist b/PhoneNumberKitTests/Info.plist index 2d166af72..80eb21b6c 100644 --- a/PhoneNumberKitTests/Info.plist +++ b/PhoneNumberKitTests/Info.plist @@ -15,10 +15,10 @@ CFBundlePackageType BNDL CFBundleShortVersionString - 0.3 + 0.6 CFBundleSignature ???? CFBundleVersion - 11 + 12 diff --git a/PhoneNumberKitTests/PartialFormatterTests.swift b/PhoneNumberKitTests/PartialFormatterTests.swift index 5799f91bb..7832cdd8d 100644 --- a/PhoneNumberKitTests/PartialFormatterTests.swift +++ b/PhoneNumberKitTests/PartialFormatterTests.swift @@ -200,7 +200,6 @@ class PartialFormatterTests: XCTestCase { func testUSTollFreeNumber() { let partialFormatter = PartialFormatter(region: "US") var testNumber = "8" - print(partialFormatter.formatPartial("800253000"), "(800) 253-000") XCTAssertEqual(partialFormatter.formatPartial(testNumber), "8") testNumber = "80" XCTAssertEqual(partialFormatter.formatPartial(testNumber), "80") @@ -221,6 +220,6 @@ class PartialFormatterTests: XCTestCase { testNumber = "8002530000" XCTAssertEqual(partialFormatter.formatPartial(testNumber), "(800) 253-0000") } - + } diff --git a/README.md b/README.md index 4bb86e632..f2f878581 100644 --- a/README.md +++ b/README.md @@ -11,7 +11,6 @@ Inspired by Google's libphonenumber. | Remaining Objectives --- | --- -📝 | AsYouType formatter for UITextField. ⚔ | Battle-test PhoneNumberKit in a major app (100k+ users). ## Features @@ -24,6 +23,7 @@ Inspired by Google's libphonenumber. :books: | Best-in-class metadata from Google's libPhoneNumber project. :trophy: | Fully tested to match the accuracy of Google's JavaScript implementation of libPhoneNumber. :iphone: | Built for iOS. Automatically grabs the default region code from the phone. +📝 | Editable (!) AsYouType formatter for UITextField. :us: | Convert country codes to country names and vice versa ## Usage @@ -52,6 +52,15 @@ let phoneNumbers = PhoneNumberKit().parseMultiple(rawNumberArray) let phoneNumbersCustomDefaultRegion = PhoneNumberKit().parseMultiple(rawNumberArray, region: "DE") ``` +To use the AsYouTypeFormatter, just replace your UITextField with a PhoneNumberTextField. + +PhoneNumberTextField automatically formats phone numbers and gives the user full editing capabilities. If you want to customize you can use the PartialFormatter directly. The default region code is automatically computed but can be overridden if needed. +```swift +let textField = PhoneNumberTextField() + +PartialFormatter().formatPartial("+336895555") // +33 6 89 55 55 +``` + You can also query countries for a dialing code or the dailing code for a given country ```swift let phoneNumberKit = PhoneNumberKit() @@ -95,5 +104,5 @@ github "marmelroy/PhoneNumberKit" ### Setting up with [CocoaPods](http://cocoapods.org/?q=PhoneNumberKit) ```ruby source 'https://github.com/CocoaPods/Specs.git' -pod 'PhoneNumberKit', '~> 0.3' +pod 'PhoneNumberKit', '~> 0.6' ``` diff --git a/examples/AsYouType/Sample/ViewController.swift b/examples/AsYouType/Sample/ViewController.swift index 93dfbaa0c..84aaae51a 100644 --- a/examples/AsYouType/Sample/ViewController.swift +++ b/examples/AsYouType/Sample/ViewController.swift @@ -21,6 +21,8 @@ class ViewController: UIViewController, CNContactPickerDelegate { super.viewDidLoad() textField.region = "FR" textField.becomeFirstResponder() + let text = PartialFormatter().formatPartial("+336895555") + print(text) } }