Skip to content

Commit

Permalink
Upgrade to Swift 5 and iOS 10
Browse files Browse the repository at this point in the history
  • Loading branch information
devcarlos committed Jul 19, 2019
1 parent 3e0f07f commit ed9e4db
Show file tree
Hide file tree
Showing 7 changed files with 44 additions and 29 deletions.
6 changes: 3 additions & 3 deletions AnyFormatKit.podspec
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Pod::Spec.new do |s|
s.name = 'AnyFormatKit'
s.version = '1.0.1'
s.version = '2.0.0'
s.summary = 'Simple text formatting in Swift.'

s.description = <<-DESC
Expand All @@ -12,8 +12,8 @@ This framework provide to format text with format like "## ##-###", where # - re
s.author = { 'luximetr' => '[email protected]' }
s.source = { :git => 'https://github.com/luximetr/AnyFormatKit.git', :tag => s.version.to_s }

s.ios.deployment_target = '8.0'
s.swift_version = '4.0'
s.ios.deployment_target = '10.0'
s.swift_version = '5.0'

s.source_files = 'Source/**/*'
end
27 changes: 13 additions & 14 deletions AnyFormatKit.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
306EBE9F1FC4669100E49BB8 /* FormatParsingTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 306EBE9E1FC4669100E49BB8 /* FormatParsingTests.swift */; };
307EA2331FAA1B5B00DE439D /* TextInputFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 307EA2191FAA1B5B00DE439D /* TextInputFormatter.swift */; };
307EA2341FAA1B5B00DE439D /* TextFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = 307EA21A1FAA1B5B00DE439D /* TextFormatter.swift */; };
307EA2411FAA1B5B00DE439D /* String+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 307EA22D1FAA1B5B00DE439D /* String+Extension.swift */; };
307F0F4222B0373E00C52AD2 /* SumTextInputFormatterWithSuffixDelete2SymbolsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 307F0F4122B0373E00C52AD2 /* SumTextInputFormatterWithSuffixDelete2SymbolsTests.swift */; };
307F0F4422B03A5B00C52AD2 /* SumTextInputFormatterWithSuffixDelete3SymbolsTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 307F0F4322B03A5B00C52AD2 /* SumTextInputFormatterWithSuffixDelete3SymbolsTests.swift */; };
307F0F4622B03CBC00C52AD2 /* SumTextInputFormatterWithSuffixReplace1SymbolTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 307F0F4522B03CBC00C52AD2 /* SumTextInputFormatterWithSuffixReplace1SymbolTests.swift */; };
Expand Down Expand Up @@ -60,6 +59,7 @@
30FF731322ADA53D005FBC38 /* DefaultTextInputFormatter1SymbolReplaceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30FF731222ADA53D005FBC38 /* DefaultTextInputFormatter1SymbolReplaceTests.swift */; };
30FF731522ADA7A4005FBC38 /* DefaultTextInputFormatter2SymbolsReplaceTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30FF731422ADA7A4005FBC38 /* DefaultTextInputFormatter2SymbolsReplaceTests.swift */; };
30FF731722ADB380005FBC38 /* DefaultTextInputFormatter3SymbolsReplace.swift in Sources */ = {isa = PBXBuildFile; fileRef = 30FF731622ADB380005FBC38 /* DefaultTextInputFormatter3SymbolsReplace.swift */; };
D8C1ABCF22E21DAE007ABE08 /* String+Extension.swift in Sources */ = {isa = PBXBuildFile; fileRef = 307EA22D1FAA1B5B00DE439D /* String+Extension.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -597,17 +597,17 @@
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 0900;
LastUpgradeCheck = 1000;
LastUpgradeCheck = 1020;
ORGANIZATIONNAME = BRANDERSTUDIO;
TargetAttributes = {
30FE6FD71FAA13D30024D1B1 = {
CreatedOnToolsVersion = 9.0.1;
LastSwiftMigration = 1000;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
};
30FE6FE01FAA13D30024D1B1 = {
CreatedOnToolsVersion = 9.0.1;
LastSwiftMigration = 1000;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
};
};
Expand Down Expand Up @@ -677,12 +677,11 @@
files = (
30C6787D2286B45000F43F9E /* SumTextFormatter.swift in Sources */,
3032CFBF21D412E1008137EE /* DefaultTextInputFormatter.swift in Sources */,
307EA2411FAA1B5B00DE439D /* String+Extension.swift in Sources */,
D8C1ABCF22E21DAE007ABE08 /* String+Extension.swift in Sources */,
30A308962072BA7300CFC062 /* CaretPositionCorrector.swift in Sources */,
3032CFC021D412E1008137EE /* DefaultTextFormatter.swift in Sources */,
30EB6CB822BB870E00447D5A /* SumFormatParser.swift in Sources */,
307EA2341FAA1B5B00DE439D /* TextFormatter.swift in Sources */,
307EA2411FAA1B5B00DE439D /* String+Extension.swift in Sources */,
30EB6CB922BB870E00447D5A /* SumTextInputFormatterCaretPositionCalculator.swift in Sources */,
30EB6CBA22BB870E00447D5A /* SumTextInputFormatter.swift in Sources */,
307EA2331FAA1B5B00DE439D /* TextInputFormatter.swift in Sources */,
Expand Down Expand Up @@ -794,7 +793,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -851,7 +850,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
Expand All @@ -874,12 +873,12 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = BundleFiles/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = Brander.AnyFormatKit;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -896,12 +895,12 @@
DYLIB_INSTALL_NAME_BASE = "@rpath";
INFOPLIST_FILE = BundleFiles/Info.plist;
INSTALL_PATH = "$(LOCAL_LIBRARY_DIR)/Frameworks";
IPHONEOS_DEPLOYMENT_TARGET = 8.0;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = Brander.AnyFormatKit;
PRODUCT_NAME = "$(TARGET_NAME:c99extidentifier)";
SKIP_INSTALL = YES;
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand All @@ -916,7 +915,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = Brander.AnyFormatKitTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -931,7 +930,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = Brander.AnyFormatKitTests;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.2;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
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 = "1000"
LastUpgradeVersion = "1020"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
12 changes: 7 additions & 5 deletions Example/iOS Example.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@
TargetAttributes = {
307EA24C1FAA1D0000DE439D = {
CreatedOnToolsVersion = 9.1;
LastSwiftMigration = 1000;
LastSwiftMigration = 1020;
ProvisioningStyle = Automatic;
};
};
Expand Down Expand Up @@ -244,7 +244,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.1;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = iphoneos;
Expand Down Expand Up @@ -297,7 +297,7 @@
GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
GCC_WARN_UNUSED_FUNCTION = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
IPHONEOS_DEPLOYMENT_TARGET = 11.1;
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
MTL_ENABLE_DEBUG_INFO = NO;
SDKROOT = iphoneos;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
Expand All @@ -313,10 +313,11 @@
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 87GS5B9N5U;
INFOPLIST_FILE = "iOS Example/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "Brander.iOS-Example";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Debug;
Expand All @@ -329,10 +330,11 @@
CODE_SIGN_STYLE = Automatic;
DEVELOPMENT_TEAM = 87GS5B9N5U;
INFOPLIST_FILE = "iOS Example/Info.plist";
IPHONEOS_DEPLOYMENT_TARGET = 10.0;
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks";
PRODUCT_BUNDLE_IDENTIFIER = "Brander.iOS-Example";
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0;
SWIFT_VERSION = 5.0;
TARGETED_DEVICE_FAMILY = "1,2";
};
name = Release;
Expand Down
15 changes: 10 additions & 5 deletions Example/iOS Example/ViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,9 @@ private extension ViewController {
phoneNumberField.backgroundColor = UIColor.black
phoneNumberField.tintColor = ColorConstants.gray

phoneNumberField.defaultTextAttributes = [
phoneNumberField.defaultTextAttributes = convertToNSAttributedStringKeyDictionary([
NSAttributedString.Key.foregroundColor.rawValue: UIColor.white,
NSAttributedString.Key.font.rawValue: UIFont.systemFont(ofSize: 22, weight: .regular)]
NSAttributedString.Key.font.rawValue: UIFont.systemFont(ofSize: 22, weight: .regular)])
phoneNumberInputController.formatter = phoneNumberFormatter
phoneNumberField.delegate = phoneNumberInputController
}
Expand All @@ -95,9 +95,9 @@ private extension ViewController {
sumInputField.tintColor = ColorConstants.gray

sumInputField.addTarget(self, action: #selector(textDidChange), for: .editingChanged)
sumInputField.defaultTextAttributes = [
NSAttributedStringKey.foregroundColor.rawValue: UIColor.white,
NSAttributedStringKey.font.rawValue: UIFont.systemFont(ofSize: 22, weight: .regular)]
sumInputField.defaultTextAttributes = convertToNSAttributedStringKeyDictionary([
NSAttributedString.Key.foregroundColor.rawValue: UIColor.white,
NSAttributedString.Key.font.rawValue: UIFont.systemFont(ofSize: 22, weight: .regular)])
sumInputController.formatter = sumFormatter
sumInputField.delegate = sumInputController
}
Expand Down Expand Up @@ -183,3 +183,8 @@ private extension UITextView {
}
}
}

// Helper function inserted by Swift 4.2 migrator.
fileprivate func convertToNSAttributedStringKeyDictionary(_ input: [String: Any]) -> [NSAttributedString.Key: Any] {
return Dictionary(uniqueKeysWithValues: input.map { key, value in (NSAttributedString.Key(rawValue: key), value)})
}
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,8 @@ class CaretPositionCorrector {
let indexes = indexesOfPatternSymbols(in: searchRange)

if let lastIndex = indexes.last {
return lastIndex.encodedOffset + 1
//return lastIndex.encodedOffset + 1
return lastIndex.utf16Offset(in: textPattern) + 1
}
return 0
}
Expand Down

0 comments on commit ed9e4db

Please sign in to comment.