diff --git a/.swift-version b/.swift-version index 5186d07..bf77d54 100644 --- a/.swift-version +++ b/.swift-version @@ -1 +1 @@ -4.0 +4.2 diff --git a/CHANGELOG.md b/CHANGELOG.md index cf38317..5a9bb2b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,7 @@ # Change Log ## [Unreleased] +* [#41](https://github.com/Blackjacx/SHSearchBar/pull/41): Swift 4.2 - [@blackjacx](https://github.com/blackjacx). ## [1.4.3] - 2018-07-12 * [#39](https://github.com/Blackjacx/SHSearchBar/pull/39): Make localized extension internal - [@blackjacx](https://github.com/blackjacx). diff --git a/Example/Podfile b/Example/Podfile index 7f9cb44..4b10920 100644 --- a/Example/Podfile +++ b/Example/Podfile @@ -1,13 +1,16 @@ platform :ios, '9.0' use_frameworks! +# ignore all warnings from all pods +inhibit_all_warnings! + target 'SHSearchBar_Example' do pod 'SHSearchBar', :path => '../' target 'SHSearchBar_Tests' do inherit! :search_paths - pod 'Quick', '~> 1.2.0' - pod 'Nimble', '~> 7.0.2' + pod 'Quick' + pod 'Nimble' end -end \ No newline at end of file +end diff --git a/Example/Podfile.lock b/Example/Podfile.lock index 0b159c4..92e7e4a 100644 --- a/Example/Podfile.lock +++ b/Example/Podfile.lock @@ -1,11 +1,11 @@ PODS: - - Nimble (7.0.3) - - Quick (1.2.0) - - SHSearchBar (1.4.2) + - Nimble (7.3.1) + - Quick (1.3.2) + - SHSearchBar (1.4.3) DEPENDENCIES: - - Nimble (~> 7.0.2) - - Quick (~> 1.2.0) + - Nimble + - Quick - SHSearchBar (from `../`) SPEC REPOS: @@ -18,10 +18,10 @@ EXTERNAL SOURCES: :path: "../" SPEC CHECKSUMS: - Nimble: 7f5a9c447a33002645a071bddafbfb24ea70e0ac - Quick: 58d203b1c5e27fff7229c4c1ae445ad7069a7a08 - SHSearchBar: 1dbf4c712c66c764c5463471f86c37b20df9bcfe + Nimble: 04f732da099ea4d153122aec8c2a88fd0c7219ae + Quick: 2623cb30d7a7f41ca62f684f679586558f483d46 + SHSearchBar: 9348be4524c9b7630891f5c0827719bc1996e55a -PODFILE CHECKSUM: b2f7b434f9f12c2e8304b00e3983b43b76652086 +PODFILE CHECKSUM: bafa9295d0d82a5003cf14c577a68b7ca4bbe61b COCOAPODS: 1.5.3 diff --git a/Example/SHSearchBar.xcodeproj/project.pbxproj b/Example/SHSearchBar.xcodeproj/project.pbxproj index 292d2a2..49db2e4 100644 --- a/Example/SHSearchBar.xcodeproj/project.pbxproj +++ b/Example/SHSearchBar.xcodeproj/project.pbxproj @@ -227,17 +227,17 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0830; - LastUpgradeCheck = 0830; + LastUpgradeCheck = 1000; ORGANIZATIONNAME = CocoaPods; TargetAttributes = { 607FACCF1AFB9204008FA782 = { CreatedOnToolsVersion = 6.3.1; DevelopmentTeam = PCW579R278; - LastSwiftMigration = 0900; + LastSwiftMigration = 1000; }; 607FACE41AFB9204008FA782 = { CreatedOnToolsVersion = 6.3.1; - LastSwiftMigration = 0900; + LastSwiftMigration = 1000; TestTargetID = 607FACCF1AFB9204008FA782; }; }; @@ -436,6 +436,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -444,12 +445,14 @@ 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; @@ -488,6 +491,7 @@ isa = XCBuildConfiguration; buildSettings = { ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_LOCALIZABILITY_NONLOCALIZED = YES; CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x"; CLANG_CXX_LIBRARY = "libc++"; CLANG_ENABLE_MODULES = YES; @@ -496,12 +500,14 @@ 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; @@ -541,8 +547,7 @@ MODULE_NAME = ExampleApp; PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; VERSIONING_SYSTEM = "apple-generic"; }; name = Debug; @@ -559,8 +564,7 @@ MODULE_NAME = ExampleApp; PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.demo.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; VERSIONING_SYSTEM = "apple-generic"; }; name = Release; @@ -570,10 +574,6 @@ baseConfigurationReference = 155C0B974831EDF00FEDD99F /* Pods-SHSearchBar_Tests.debug.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(inherited)", - ); GCC_PREPROCESSOR_DEFINITIONS = ( "DEBUG=1", "$(inherited)", @@ -582,8 +582,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SHSearchBar_Example.app/SHSearchBar_Example"; }; name = Debug; @@ -593,16 +592,11 @@ baseConfigurationReference = 55ED08248C3B1B7D84327940 /* Pods-SHSearchBar_Tests.release.xcconfig */; buildSettings = { BUNDLE_LOADER = "$(TEST_HOST)"; - FRAMEWORK_SEARCH_PATHS = ( - "$(SDKROOT)/Developer/Library/Frameworks", - "$(inherited)", - ); INFOPLIST_FILE = Tests/Info.plist; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "org.cocoapods.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SHSearchBar_Example.app/SHSearchBar_Example"; }; name = Release; diff --git a/Example/SHSearchBar.xcodeproj/xcshareddata/xcschemes/SHSearchBar-Example.xcscheme b/Example/SHSearchBar.xcodeproj/xcshareddata/xcschemes/SHSearchBar-Example.xcscheme index 03a0132..7bed84a 100644 --- a/Example/SHSearchBar.xcodeproj/xcshareddata/xcschemes/SHSearchBar-Example.xcscheme +++ b/Example/SHSearchBar.xcodeproj/xcshareddata/xcschemes/SHSearchBar-Example.xcscheme @@ -1,6 +1,6 @@ Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]? = [:]) -> Bool { return true } diff --git a/Example/SHSearchBar/SearchBarTitleView.swift b/Example/SHSearchBar/SearchBarTitleView.swift index 2c8b7bb..9b060ef 100644 --- a/Example/SHSearchBar/SearchBarTitleView.swift +++ b/Example/SHSearchBar/SearchBarTitleView.swift @@ -40,7 +40,7 @@ class SearchbarTitleView: UIView { // This is important to make the title view expanding from left to right override var intrinsicContentSize: CGSize { - return UILayoutFittingExpandedSize + return UIView.layoutFittingExpandedSize } } diff --git a/Example/Tests/SHSearchBarSpec.swift b/Example/Tests/SHSearchBarSpec.swift index 30e1115..e9e3505 100644 --- a/Example/Tests/SHSearchBarSpec.swift +++ b/Example/Tests/SHSearchBarSpec.swift @@ -642,7 +642,7 @@ class SharedConfiguration: QuickConfiguration { expected[.foregroundColor] = searchbar.isActive ? expectedTextColor : expectedTextColor?.withAlphaComponent(0.5) for key in expected.keys { - guard let value = attributes[key.rawValue] as? UIColor, let expectedValue = expected[key] as? UIColor else { + guard let value = attributes[key] as? UIColor, let expectedValue = expected[key] as? UIColor else { XCTFail("Value or expected value not found for key \(key)") return } diff --git a/Gemfile.lock b/Gemfile.lock index 340a1a0..1e19d4e 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -9,7 +9,7 @@ GEM tzinfo (~> 1.1) addressable (2.5.2) public_suffix (>= 2.0.2, < 4.0) - atomos (0.1.2) + atomos (0.1.3) babosa (1.0.2) claide (1.0.2) claide-plugins (0.9.2) @@ -45,7 +45,7 @@ GEM nap cocoapods-search (1.0.0) cocoapods-stats (1.0.0) - cocoapods-trunk (1.3.0) + cocoapods-trunk (1.3.1) nap (>= 0.8, < 2.0) netrc (~> 0.11) cocoapods-try (1.1.0) @@ -56,14 +56,14 @@ GEM concurrent-ruby (1.0.5) cork (0.3.0) colored2 (~> 3.1) - danger (5.6.2) + danger (5.6.7) claide (~> 1.0) claide-plugins (>= 0.9.2) colored2 (~> 3.1) cork (~> 0.1) faraday (~> 0.9) faraday-http-cache (~> 1.0) - git (~> 1) + git (~> 1.5) kramdown (~> 1.5) no_proxy_fix octokit (~> 4.7) @@ -74,7 +74,7 @@ GEM danger (~> 5.0) danger-plugin-api (1.0.0) danger (> 2.0) - danger-swiftlint (0.17.0) + danger-swiftlint (0.17.3) danger rake (> 10) thor (~> 0.19) @@ -86,7 +86,7 @@ GEM emoji_regex (0.1.1) escape (0.0.4) excon (0.62.0) - faraday (0.15.2) + faraday (0.15.3) multipart-post (>= 1.2, < 3) faraday-cookie_jar (0.0.6) faraday (>= 0.7.4) @@ -95,8 +95,8 @@ GEM faraday (~> 0.8) faraday_middleware (0.12.2) faraday (>= 0.7.4, < 1.0) - fastimage (2.1.3) - fastlane (2.99.1) + fastimage (2.1.4) + fastlane (2.105.2) CFPropertyList (>= 2.3, < 4.0.0) addressable (>= 2.3, < 3.0.0) babosa (>= 1.0.2, < 2.0.0) @@ -111,7 +111,7 @@ GEM faraday_middleware (~> 0.9) fastimage (>= 2.1.0, < 3.0.0) gh_inspector (>= 1.1.2, < 2.0.0) - google-api-client (>= 0.21.2, < 0.22.0) + google-api-client (>= 0.21.2, < 0.24.0) highline (>= 1.7.2, < 2.0.0) json (< 3.0.0) mini_magick (~> 4.5.1) @@ -120,7 +120,7 @@ GEM multipart-post (~> 2.0.0) plist (>= 3.1.0, < 4.0.0) public_suffix (~> 2.0.0) - rubyzip (>= 1.2.1, < 2.0.0) + rubyzip (>= 1.2.2, < 2.0.0) security (= 0.1.3) simctl (~> 1.6.3) slack-notifier (>= 2.0.0, < 3.0.0) @@ -129,28 +129,28 @@ GEM tty-screen (>= 0.6.3, < 1.0.0) tty-spinner (>= 0.8.0, < 1.0.0) word_wrap (~> 1.0.0) - xcodeproj (>= 1.5.7, < 2.0.0) - xcpretty (~> 0.2.8) + xcodeproj (>= 1.6.0, < 2.0.0) + xcpretty (~> 0.3.0) xcpretty-travis-formatter (>= 0.0.3) fastlane-plugin-changelog (0.9.0) fourflusher (2.0.1) fuzzy_match (2.0.4) gh_inspector (1.1.3) - git (1.4.0) - google-api-client (0.21.2) + git (1.5.0) + google-api-client (0.23.9) addressable (~> 2.5, >= 2.5.1) googleauth (>= 0.5, < 0.7.0) httpclient (>= 2.8.1, < 3.0) mime-types (~> 3.0) representable (~> 3.0) retriable (>= 2.0, < 4.0) - googleauth (0.6.2) + signet (~> 0.9) + googleauth (0.6.6) faraday (~> 0.12) jwt (>= 1.4, < 3.0) - logging (~> 2.0) memoist (~> 0.12) multi_json (~> 1.11) - os (~> 0.9) + os (>= 0.9, < 2.0) signet (~> 0.7) highline (1.7.10) http-cookie (1.0.3) @@ -161,17 +161,13 @@ GEM json (2.1.0) jwt (2.1.0) kramdown (1.17.0) - little-plugger (1.1.4) - logging (2.2.2) - little-plugger (~> 1.1) - multi_json (~> 1.10) memoist (0.16.0) - mime-types (3.1) + mime-types (3.2.2) mime-types-data (~> 3.2015) - mime-types-data (3.2016.0521) + mime-types-data (3.2018.0812) mini_magick (4.5.1) minitest (5.11.3) - molinillo (0.6.5) + molinillo (0.6.6) multi_json (1.13.1) multi_xml (0.6.0) multipart-post (2.0.0) @@ -180,10 +176,10 @@ GEM naturally (2.2.0) netrc (0.11.0) no_proxy_fix (0.1.2) - octokit (4.9.0) + octokit (4.12.0) sawyer (~> 0.8.0, >= 0.5.3) open4 (1.3.4) - os (0.9.6) + os (1.0.0) plist (3.4.0) public_suffix (2.0.5) rake (12.3.1) @@ -194,12 +190,12 @@ GEM retriable (3.1.2) rouge (2.0.7) ruby-macho (1.2.0) - rubyzip (1.2.1) + rubyzip (1.2.2) sawyer (0.8.1) addressable (>= 2.3.5, < 2.6) faraday (~> 0.8, < 1.0) security (0.1.3) - signet (0.8.1) + signet (0.10.0) addressable (~> 2.3) faraday (~> 0.9) jwt (>= 1.5, < 3.0) @@ -213,8 +209,8 @@ GEM unicode-display_width (~> 1.1, >= 1.1.1) thor (0.20.0) thread_safe (0.3.6) - tty-cursor (0.5.0) - tty-screen (0.6.4) + tty-cursor (0.6.0) + tty-screen (0.6.5) tty-spinner (0.8.0) tty-cursor (>= 0.5.0) tzinfo (1.2.5) @@ -225,19 +221,19 @@ GEM unf_ext (0.0.7.5) unicode-display_width (1.4.0) word_wrap (1.0.0) - xcodeproj (1.5.9) + xcodeproj (1.6.0) CFPropertyList (>= 2.3.3, < 4.0) - atomos (~> 0.1.2) + atomos (~> 0.1.3) claide (>= 1.0.2, < 2.0) colored2 (~> 3.1) - nanaimo (~> 0.2.5) - xcov (1.4.3) + nanaimo (~> 0.2.6) + xcov (1.5.0) fastlane (>= 2.82.0, < 3.0.0) multipart-post slack-notifier terminal-table xcodeproj - xcpretty (0.2.8) + xcpretty (0.3.0) rouge (~> 2.0.7) xcpretty-travis-formatter (1.0.0) xcpretty (~> 0.2, >= 0.0.7) diff --git a/SHSearchBar/Classes/SHSearchBar.swift b/SHSearchBar/Classes/SHSearchBar.swift index 6878eee..3185db5 100644 --- a/SHSearchBar/Classes/SHSearchBar.swift +++ b/SHSearchBar/Classes/SHSearchBar.swift @@ -208,7 +208,7 @@ public class SHSearchBar: UIView, SHSearchBarDelegate { var textAttributes = config.textAttributes textAttributes[.foregroundColor] = textColor - textField.defaultTextAttributes = SHSearchBarConfig.convert(textAttributes: textAttributes) + textField.defaultTextAttributes = textAttributes let normalAttributes = config.cancelButtonTextAttributes cancelButton.setAttributedTitle(NSAttributedString(string: config.cancelButtonTitle, attributes: normalAttributes), for: .normal) diff --git a/SHSearchBar/Classes/SHSearchBarConfig.swift b/SHSearchBar/Classes/SHSearchBarConfig.swift index b61ffb6..c311298 100644 --- a/SHSearchBar/Classes/SHSearchBarConfig.swift +++ b/SHSearchBar/Classes/SHSearchBarConfig.swift @@ -16,16 +16,7 @@ public struct SHSearchBarConfig { public var rasterSize: CGFloat = 11.0 /// The attributes to format the searchbars text. - public var textAttributes: [NSAttributedStringKey : Any] = [.foregroundColor : defaultTextForegroundColor] - - /// Convenience computed property because UITextField.defaultTextAttributes require `[String:Any]`. - public static func convert(textAttributes: [NSAttributedStringKey: Any]) -> [String: Any] { - var attributes: [String: Any] = [:] - for attr in textAttributes { - attributes[attr.key.rawValue] = attr.value - } - return attributes - } + public var textAttributes: [NSAttributedString.Key : Any] = [.foregroundColor : defaultTextForegroundColor] /// The textContentType property is to provide the keyboard with extra information about the semantic intent of the text document. public var textContentType: String? = nil @@ -37,22 +28,22 @@ public struct SHSearchBarConfig { public var cancelButtonTitle: String = "sb.general.cancel".localized /// The text attributes to style the cancel button. - public var cancelButtonTextAttributes: [NSAttributedStringKey : Any] = [.foregroundColor : defaultTextForegroundColor] + public var cancelButtonTextAttributes: [NSAttributedString.Key : Any] = [.foregroundColor : defaultTextForegroundColor] /// The left accessory view of the searchbar. For searchbars there is typically a search glass. public var leftView: UIView? = nil /// The left view mode of the searchbar regarding to a leftView. - public var leftViewMode: UITextFieldViewMode = .never + public var leftViewMode: UITextField.ViewMode = .never /// The right accessory view of the searchbar. For searchbars there is typically a search glass. public var rightView: UIView? = nil /// The right view mode of the searchbar regarding to a rightView. - public var rightViewMode: UITextFieldViewMode = .always + public var rightViewMode: UITextField.ViewMode = .always /// Controls when to show the clear button. - public var clearButtonMode: UITextFieldViewMode = .whileEditing + public var clearButtonMode: UITextField.ViewMode = .whileEditing // MARK: - Lifecycle