diff --git a/.swift-version b/.swift-version index 389f774..8012ebb 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -4.0 \ No newline at end of file +4.2 \ No newline at end of file diff --git a/Highlighter.podspec b/Highlighter.podspec index b88ccc8..1264512 100644 --- a/Highlighter.podspec +++ b/Highlighter.podspec @@ -8,7 +8,7 @@ Pod::Spec.new do |s| s.name = 'Highlighter' - s.version = '1.2.0' + s.version = '1.3.0' s.summary = 'Highlight whatever you want!' s.description = <<-DESC @@ -22,7 +22,7 @@ Pod::Spec.new do |s| s.source = { :git => 'https://github.com/younatics/Highlighter.git', :tag => s.version.to_s } s.source_files = 'Highlighter/*.swift' - s.ios.deployment_target = '8.0' + s.ios.deployment_target = '9.0' s.frameworks = 'Foundation' s.requires_arc = true end diff --git a/Highlighter.xcodeproj/project.pbxproj b/Highlighter.xcodeproj/project.pbxproj index 53791ac..a892dd5 100644 --- a/Highlighter.xcodeproj/project.pbxproj +++ b/Highlighter.xcodeproj/project.pbxproj @@ -207,13 +207,13 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 10.3; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; VERSIONING_SYSTEM = "apple-generic"; VERSION_INFO_PREFIX = ""; @@ -262,11 +262,11 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 10.3; + IPHONEOS_DEPLOYMENT_TARGET = 9.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; VERSIONING_SYSTEM = "apple-generic"; @@ -292,7 +292,7 @@ SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -313,7 +313,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Release; }; diff --git a/Highlighter.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/Highlighter.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/Highlighter.xcodeproj/project.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/Highlighter/Highlightable.swift b/Highlighter/Highlightable.swift index 471576b..16c1a61 100644 --- a/Highlighter/Highlightable.swift +++ b/Highlighter/Highlightable.swift @@ -12,11 +12,11 @@ public protocol Highlightable: class { var textValue: String? { get } var attributedTextValue: NSAttributedString? { get set } - func highlight(text: String, normal normalAttributes: [NSAttributedStringKey : Any]?, highlight highlightAttributes: [NSAttributedStringKey : Any]?) + func highlight(text: String, normal normalAttributes: [NSAttributedString.Key : Any]?, highlight highlightAttributes: [NSAttributedString.Key : Any]?) } extension Highlightable { - public func highlight(text: String, normal normalAttributes: [NSAttributedStringKey : Any]?, highlight highlightAttributes: [NSAttributedStringKey : Any]?) { + public func highlight(text: String, normal normalAttributes: [NSAttributedString.Key : Any]?, highlight highlightAttributes: [NSAttributedString.Key : Any]?) { guard let inputText = self.textValue else { return } let highlightRanges = inputText.lowercased().ranges(of: text) diff --git a/Highlighter/HighlightableContainer.swift b/Highlighter/HighlightableContainer.swift index e2ac542..f370a78 100644 --- a/Highlighter/HighlightableContainer.swift +++ b/Highlighter/HighlightableContainer.swift @@ -16,11 +16,11 @@ public protocol HighlightableContainer: class { /// - normalAttributes: Attributes to apply to non-matching text /// - highlightAttributes: Attributes to apply (highlight) to matching text /// - type: (optional) Only search `Highlightable`s of this type - func highlight(text: String, normal normalAttributes: [NSAttributedStringKey : Any]?, highlight highlightAttributes: [NSAttributedStringKey : Any]?, type: Highlightable.Type?) + func highlight(text: String, normal normalAttributes: [NSAttributedString.Key : Any]?, highlight highlightAttributes: [NSAttributedString.Key : Any]?, type: Highlightable.Type?) } extension HighlightableContainer { - public func highlight(text: String, normal normalAttributes: [NSAttributedStringKey : Any]?, highlight highlightAttributes: [NSAttributedStringKey : Any]?, type: Highlightable.Type? = nil) { + public func highlight(text: String, normal normalAttributes: [NSAttributedString.Key : Any]?, highlight highlightAttributes: [NSAttributedString.Key : Any]?, type: Highlightable.Type? = nil) { let mirror = Mirror(reflecting: self) mirror.children .flatMap { $0.value as? Highlightable } diff --git a/Highlighter/NSAttributedString+Extensions.swift b/Highlighter/NSAttributedString+Extensions.swift index 58a1e14..54686de 100644 --- a/Highlighter/NSAttributedString+Extensions.swift +++ b/Highlighter/NSAttributedString+Extensions.swift @@ -9,7 +9,7 @@ import Foundation extension NSAttributedString { - static func highlight(ranges: [Range], at searchText: String, in originText: String, normal normalAttributes: [NSAttributedStringKey : Any]?, highlight highlightAttributes: [NSAttributedStringKey : Any]?) -> NSAttributedString { + static func highlight(ranges: [Range], at searchText: String, in originText: String, normal normalAttributes: [NSAttributedString.Key : Any]?, highlight highlightAttributes: [NSAttributedString.Key : Any]?) -> NSAttributedString { let startString = String(originText[.. NSMutableAttributedString { + private static func continueAttribute(originText: String, upperBound: String.Index, lowerBound: String.Index, normalAttributes: [NSAttributedString.Key : Any]?) -> NSMutableAttributedString { let range = Range(uncheckedBounds: (upperBound, lowerBound)) let continueString = String(originText[range]) let continueAttributeString = NSMutableAttributedString(string: continueString, attributes: normalAttributes) return continueAttributeString } - private static func containAttribute(originText: String, bound: Range, attributes: [NSAttributedStringKey : Any]?) -> NSMutableAttributedString { + private static func containAttribute(originText: String, bound: Range, attributes: [NSAttributedString.Key : Any]?) -> NSMutableAttributedString { let containedString = String(originText[bound]) let containedAttributeString = NSMutableAttributedString(string: containedString, attributes: attributes) return containedAttributeString } - private static func endAttribute(originText: String, bound: String.Index, normalAttributes: [NSAttributedStringKey : Any]?) -> NSMutableAttributedString { + private static func endAttribute(originText: String, bound: String.Index, normalAttributes: [NSAttributedString.Key : Any]?) -> NSMutableAttributedString { let endString = String(originText[bound...]) let endAttributeString = NSMutableAttributedString(string: endString, attributes: normalAttributes) return endAttributeString