Skip to content

Commit

Permalink
Merge pull request #148 from himargin/master
Browse files Browse the repository at this point in the history
update the pod and the podfile to swift 4.2
  • Loading branch information
DannyVancura authored Nov 2, 2018
2 parents b6c7358 + bb41255 commit 7afc4a3
Show file tree
Hide file tree
Showing 16 changed files with 90 additions and 71 deletions.
1 change: 0 additions & 1 deletion .swift-version

This file was deleted.

12 changes: 6 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,17 +3,17 @@
# * https://github.com/supermarin/xcpretty#usage

language: objective-c
osx_image: xcode9
osx_image: xcode10
# cache: cocoapods
# podfile: Example/Podfile
# before_install:
# - gem install cocoapods # Since Travis is not always on latest version
# - pod install --project-directory=Example
script:
- xcodebuild test -project Caishen.xcodeproj -scheme CaishenTests -destination 'platform=iOS Simulator,name=iPhone 6,OS=11.0'
- pod lib lint --allow-warnings
- xcodebuild test -project Caishen.xcodeproj -scheme CaishenTests -destination 'platform=iOS Simulator,name=iPhone XS,OS=12.0'
- bundle exec pod lib lint --allow-warnings

before_install:
- rvm install ruby-2.3.1 && rvm use 2.3.1
- gem install bundler
- gem install cocoapods --no-rdoc --no-ri --no-document --quiet
- rvm install ruby-2.3.1 && rvm use 2.3.1
- gem install bundler
- gem install cocoapods --no-rdoc --no-ri --no-document --quiet
3 changes: 2 additions & 1 deletion Caishen.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ Pod::Spec.new do |s|
# * Think: What does it do? Why did you write it? What is the focus?
# * Try to keep it short, snappy and to the point.
# * Write the description between the DESC delimiters below.
# * Finally, don't worry about the indent, CocoaPods strips it!
# * Finally, don't worry about the indent, CocoaPods strips it!
s.description = <<-DESC
Caishen provides a text field to enter credit card (or other card) information and validates most of this information on its own.
DESC
Expand All @@ -27,6 +27,7 @@ Pod::Spec.new do |s|

s.platform = :ios, '8.0'
s.requires_arc = true
s.swift_version = '4.2'

s.source_files = 'Pod/Classes/**/*'
s.resources = ['Pod/Assets/*', 'Pod/Resources/*']
Expand Down
26 changes: 21 additions & 5 deletions Caishen.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0730;
LastUpgradeCheck = 0810;
LastUpgradeCheck = 1000;
ORGANIZATIONNAME = "Prolific Interactive";
TargetAttributes = {
2FDD150F1CC7B0B90086CEAC = {
Expand Down Expand Up @@ -489,14 +489,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -540,14 +548,22 @@
CLANG_CXX_LIBRARY = "libc++";
CLANG_ENABLE_MODULES = YES;
CLANG_ENABLE_OBJC_ARC = YES;
CLANG_WARN_BLOCK_CAPTURE_AUTORELEASING = YES;
CLANG_WARN_BOOL_CONVERSION = YES;
CLANG_WARN_COMMA = YES;
CLANG_WARN_CONSTANT_CONVERSION = YES;
CLANG_WARN_DEPRECATED_OBJC_IMPLEMENTATIONS = YES;
CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
CLANG_WARN_EMPTY_BODY = YES;
CLANG_WARN_ENUM_CONVERSION = YES;
CLANG_WARN_INFINITE_RECURSION = YES;
CLANG_WARN_INT_CONVERSION = YES;
CLANG_WARN_NON_LITERAL_NULL_CONVERSION = YES;
CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES;
CLANG_WARN_OBJC_LITERAL_CONVERSION = YES;
CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
CLANG_WARN_RANGE_LOOP_ANALYSIS = YES;
CLANG_WARN_STRICT_PROTOTYPES = YES;
CLANG_WARN_SUSPICIOUS_MOVE = YES;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
Expand Down Expand Up @@ -589,7 +605,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.prolificinteractive.Caishen;
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -608,7 +624,7 @@
PRODUCT_NAME = "$(TARGET_NAME)";
SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand All @@ -619,7 +635,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = com.prolificinteractive.CaishenTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
};
name = Debug;
};
Expand All @@ -631,7 +647,7 @@
PRODUCT_BUNDLE_IDENTIFIER = com.prolificinteractive.CaishenTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 3.0;
SWIFT_VERSION = 4.2;
};
name = Release;
};
Expand Down
2 changes: 1 addition & 1 deletion Caishen.xcodeproj/xcshareddata/xcschemes/Caishen.xcscheme
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0810"
LastUpgradeVersion = "1000"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0810"
LastUpgradeVersion = "1000"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
2 changes: 1 addition & 1 deletion CaishenTests/CardExpiryValidatorTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ class CardExpiryValidatorTests: XCTestCase {

for i in 0..<shouldBeNil.count {
let obj = shouldBeNil[i]
XCTAssertNil(obj, "Object \(i) should be nil, but is \(obj?.description)")
XCTAssertNil(obj, "Object \(i) should be nil, but is \(obj?.description ?? "" )")
}

for i in 0..<shouldNotBeNil.count {
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
source 'https://rubygems.org'

gem 'cocoapods', '1.1.1'
gem 'cocoapods'
77 changes: 40 additions & 37 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,73 +1,76 @@
GEM
remote: https://rubygems.org/
specs:
CFPropertyList (2.3.3)
activesupport (4.2.7.1)
CFPropertyList (3.0.0)
activesupport (4.2.10)
i18n (~> 0.7)
json (~> 1.7, >= 1.7.7)
minitest (~> 5.1)
thread_safe (~> 0.3, >= 0.3.4)
tzinfo (~> 1.1)
claide (1.0.1)
cocoapods (1.1.1)
atomos (0.1.3)
claide (1.0.2)
cocoapods (1.5.3)
activesupport (>= 4.0.2, < 5)
claide (>= 1.0.1, < 2.0)
cocoapods-core (= 1.1.1)
cocoapods-deintegrate (>= 1.0.1, < 2.0)
cocoapods-downloader (>= 1.1.2, < 2.0)
claide (>= 1.0.2, < 2.0)
cocoapods-core (= 1.5.3)
cocoapods-deintegrate (>= 1.0.2, < 2.0)
cocoapods-downloader (>= 1.2.0, < 2.0)
cocoapods-plugins (>= 1.0.0, < 2.0)
cocoapods-search (>= 1.0.0, < 2.0)
cocoapods-stats (>= 1.0.0, < 2.0)
cocoapods-trunk (>= 1.1.1, < 2.0)
cocoapods-trunk (>= 1.3.0, < 2.0)
cocoapods-try (>= 1.1.0, < 2.0)
colored (~> 1.2)
colored2 (~> 3.1)
escape (~> 0.0.4)
fourflusher (~> 2.0.1)
gh_inspector (~> 1.0)
molinillo (~> 0.5.1)
molinillo (~> 0.6.5)
nap (~> 1.0)
xcodeproj (>= 1.3.3, < 2.0)
cocoapods-core (1.1.1)
activesupport (>= 4.0.2, < 5)
ruby-macho (~> 1.1)
xcodeproj (>= 1.5.7, < 2.0)
cocoapods-core (1.5.3)
activesupport (>= 4.0.2, < 6)
fuzzy_match (~> 2.0.4)
nap (~> 1.0)
cocoapods-deintegrate (1.0.1)
cocoapods-downloader (1.1.2)
cocoapods-deintegrate (1.0.2)
cocoapods-downloader (1.2.2)
cocoapods-plugins (1.0.0)
nap
cocoapods-search (1.0.0)
cocoapods-stats (1.0.0)
cocoapods-trunk (1.1.1)
cocoapods-trunk (1.3.1)
nap (>= 0.8, < 2.0)
netrc (= 0.7.8)
netrc (~> 0.11)
cocoapods-try (1.1.0)
colored (1.2)
colored2 (3.1.2)
concurrent-ruby (1.0.5)
escape (0.0.4)
fourflusher (2.0.1)
fuzzy_match (2.0.4)
gh_inspector (1.0.2)
i18n (0.7.0)
json (1.8.3)
minitest (5.9.1)
molinillo (0.5.3)
nanaimo (0.2.0)
gh_inspector (1.1.3)
i18n (0.9.5)
concurrent-ruby (~> 1.0)
minitest (5.11.3)
molinillo (0.6.6)
nanaimo (0.2.6)
nap (1.1.0)
netrc (0.7.8)
thread_safe (0.3.5)
tzinfo (1.2.2)
netrc (0.11.0)
ruby-macho (1.3.1)
thread_safe (0.3.6)
tzinfo (1.2.5)
thread_safe (~> 0.1)
xcodeproj (1.4.1)
CFPropertyList (~> 2.3.3)
activesupport (>= 3)
claide (>= 1.0.1, < 2.0)
colored (~> 1.2)
nanaimo (~> 0.2.0)
xcodeproj (1.7.0)
CFPropertyList (>= 2.3.3, < 4.0)
atomos (~> 0.1.3)
claide (>= 1.0.2, < 2.0)
colored2 (~> 3.1)
nanaimo (~> 0.2.6)

PLATFORMS
ruby

DEPENDENCIES
cocoapods (= 1.1.1)
cocoapods

BUNDLED WITH
1.13.6
1.16.1
4 changes: 2 additions & 2 deletions Pod/Classes/Cards/CardTypeRegister.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ open class CardTypeRegister {
/**
The default card type register, shared among all CardTextFields.
*/
open static let sharedCardTypeRegister = CardTypeRegister(registeredCardTypes: CardTypeRegister.defaultCardTypes)
public static let sharedCardTypeRegister = CardTypeRegister(registeredCardTypes: CardTypeRegister.defaultCardTypes)

/// An array of all registered card types. You can edit this array with `registerCardType`, `unregisterCardType` or `setRegisteredCardTypes`.
open private(set) var registeredCardTypes: [CardType]
Expand All @@ -37,7 +37,7 @@ open class CardTypeRegister {
}

/// An array with the default card types provided by Caishen.
open static let defaultCardTypes: [CardType] = [
public static let defaultCardTypes: [CardType] = [
AmericanExpress(),
ChinaUnionPay(),
DinersClub(),
Expand Down
10 changes: 5 additions & 5 deletions Pod/Classes/Format/CardNumberFormatter.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import UIKit
public final class CardNumberFormatter {

/// The separator which is used to separate different groups of a card number.
open let separator: String
public let separator: String

/// The card type register which is used to access accepted card types. Formatting will only take place for card numbers whose card type can be found in this property.
private var cardTypeRegister: CardTypeRegister
Expand All @@ -36,7 +36,7 @@ public final class CardNumberFormatter {
- returns: The unformatted card number string representation.
*/
open func unformat(cardNumber: String) -> String {
public func unformat(cardNumber: String) -> String {
return cardNumber.replacingOccurrences(of: self.separator, with: "")
}

Expand All @@ -47,7 +47,7 @@ public final class CardNumberFormatter {
- returns: Formatted card number string.
*/
open func format(cardNumber: String) -> String {
public func format(cardNumber: String) -> String {
let regex: NSRegularExpression

let cardType = cardTypeRegister.cardType(for: Number(rawValue: cardNumber))
Expand Down Expand Up @@ -77,7 +77,7 @@ public final class CardNumberFormatter {
- returns: The index of the cursor position or nil, if no selected text was found.
*/
open func cursorPositionAfterUnformatting(_ text: String, in textField: UITextField) -> Int? {
public func cursorPositionAfterUnformatting(_ text: String, in textField: UITextField) -> Int? {
guard let selectedRange = textField.selectedTextRange else {
return nil
}
Expand Down Expand Up @@ -162,7 +162,7 @@ public final class CardNumberFormatter {
- parameter textField: The text field whose text should be changed.
- parameter string: The new string. This might be unformatted or badly formatted and will be formatted properly before being inserted into `textField`.
*/
open func format(range: NSRange, inTextField textField: UITextField, andReplaceWith string: String) {
public func format(range: NSRange, inTextField textField: UITextField, andReplaceWith string: String) {
let newValueUnformatted = unformat(cardNumber: NSString(string: textField.text ?? "").replacingCharacters(in: range, with: string))
let oldValueUnformatted = unformat(cardNumber: textField.text ?? "")

Expand Down
4 changes: 2 additions & 2 deletions Pod/Classes/UI/CardTextField+CardInfoTextFieldDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ extension CardTextField: CardInfoTextFieldDelegate {
private func addDateInvalidityObserver() {
NotificationCenter.default.addObserver(self,
selector: #selector(notifyExpiryInvalidity),
name: NSNotification.Name.UIAccessibilityAnnouncementDidFinish,
name: UIAccessibility.announcementDidFinishNotification,
object: nil)
}

Expand All @@ -110,7 +110,7 @@ extension CardTextField: CardInfoTextFieldDelegate {
*/
@objc private func notifyExpiryInvalidity() {
let localizedString = Localization.InvalidExpirationDate.localizedStringWithComment("The expiration date entered is not valid")
UIAccessibilityPostNotification(UIAccessibilityAnnouncementNotification, localizedString)
UIAccessibility.post(notification: UIAccessibility.Notification.announcement, argument: localizedString)
NotificationCenter.default.removeObserver(self)
}
}
8 changes: 4 additions & 4 deletions Pod/Classes/UI/CardTextField.swift
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,7 @@ open class CardTextField: UITextField, NumberInputTextFieldDelegate {
fatalError("The nib is expected to contain a UIView as root element.")
}

numberInputTextField.contentMode = UIViewContentMode.redraw
numberInputTextField.contentMode = UIView.ContentMode.redraw

clipsToBounds = true

Expand Down Expand Up @@ -400,7 +400,7 @@ open class CardTextField: UITextField, NumberInputTextFieldDelegate {
*/
private func setupTargetsForEditingBegin() {
// Show the full number text field, if editing began on it
numberInputTextField?.addTarget(self, action: #selector(moveCardNumberInAnimated), for: UIControlEvents.editingDidBegin)
numberInputTextField?.addTarget(self, action: #selector(moveCardNumberInAnimated), for: UIControl.Event.editingDidBegin)

// Show CVC image if the cvcTextField is selected, show card image otherwise
let nonCVCTextFields: [UITextField?] = [numberInputTextField, monthTextField, yearTextField]
Expand Down Expand Up @@ -430,7 +430,7 @@ open class CardTextField: UITextField, NumberInputTextFieldDelegate {
if let buttonImage = cardTextFieldDelegate?.cardTextFieldShouldShowAccessoryImage(self) {
let scaledImage = buttonImage.resizableImage(withCapInsets: UIEdgeInsets.zero, resizingMode: .stretch)
accessoryButton?.titleLabel?.text = nil
accessoryButton?.setImage(scaledImage, for: UIControlState())
accessoryButton?.setImage(scaledImage, for: UIControl.State())
accessoryButton?.tintColor = numberInputTextField?.textColor
}

Expand Down Expand Up @@ -602,7 +602,7 @@ open class CardTextField: UITextField, NumberInputTextFieldDelegate {
// Return false if any of this text field's subviews is already first responder.
// Otherwise let `numberInputTextField` become the first responder.
if [numberInputTextField,monthTextField,yearTextField,cvcTextField]
.flatMap({return $0.isFirstResponder})
.map({return $0.isFirstResponder})
.reduce(true, {$0 && $1}) {
return false
}
Expand Down
Loading

0 comments on commit 7afc4a3

Please sign in to comment.