From 45824d373d8df77aaddd83f64c0d86f1bec96238 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Peter=20B=C3=B8dskov?= Date: Thu, 28 Mar 2019 09:16:01 +0100 Subject: [PATCH] upgrades Spinner framework, tests and demo to Swift 4.2 --- .travis.yml | 10 +++--- Spinner.xcodeproj/project.pbxproj | 30 +++++++++-------- .../xcschemes/Spinner-tvOS.xcscheme | 4 +-- .../xcshareddata/xcschemes/Spinner.xcscheme | 4 +-- Spinner/Spinner.swift | 14 ++++---- .../SpinnerDemo.xcodeproj/project.pbxproj | 32 +++++++++++++++---- .../SpinnerDemo/SpinnerDemo/AppDelegate.swift | 2 +- SpinnerTests/SpinnerTests.swift | 12 +++---- 8 files changed, 63 insertions(+), 45 deletions(-) diff --git a/.travis.yml b/.travis.yml index 500699e..f776dcc 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: swift -osx_image: xcode9.1 +osx_image: xcode10.1 branches: only: - master @@ -10,12 +10,12 @@ env: - IOS_FRAMEWORK_SCHEME="Spinner" - TVOS_FRAMEWORK_SCHEME="Spinner-tvOS" - - IOS_SDK=iphonesimulator11.1 - - TVOS_SDK=appletvsimulator11.1 + - IOS_SDK=iphonesimulator12.1 + - TVOS_SDK=appletvsimulator12.1 matrix: - - DESTINATION="OS=11.1,name=iPhone 6S Plus" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK" RUN_TESTS="YES" - - DESTINATION="OS=11.1,name=Apple TV 4K (at 1080p)" SCHEME="$TVOS_FRAMEWORK_SCHEME" SDK="$TVOS_SDK" RUN_TESTS="YES" + - DESTINATION="OS=12.1,name=iPhone 6S Plus" SCHEME="$IOS_FRAMEWORK_SCHEME" SDK="$IOS_SDK" RUN_TESTS="YES" + - DESTINATION="OS=12.1,name=Apple TV 4K (at 1080p)" SCHEME="$TVOS_FRAMEWORK_SCHEME" SDK="$TVOS_SDK" RUN_TESTS="YES" script: - set -o pipefail diff --git a/Spinner.xcodeproj/project.pbxproj b/Spinner.xcodeproj/project.pbxproj index 7af7cc5..676ade3 100644 --- a/Spinner.xcodeproj/project.pbxproj +++ b/Spinner.xcodeproj/project.pbxproj @@ -244,7 +244,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0800; - LastUpgradeCheck = 0910; + LastUpgradeCheck = 1010; ORGANIZATIONNAME = Nodes; TargetAttributes = { 275BCA281C57C50A00FF3647 = { @@ -381,12 +381,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; @@ -437,12 +439,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; @@ -490,8 +494,8 @@ PRODUCT_NAME = Spinner; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_SWIFT3_OBJC_INFERENCE = On; - SWIFT_VERSION = 4.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -511,8 +515,8 @@ PRODUCT_NAME = Spinner; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_SWIFT3_OBJC_INFERENCE = On; - SWIFT_VERSION = 4.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.2; }; name = Release; }; @@ -530,8 +534,8 @@ PRODUCT_BUNDLE_IDENTIFIER = dk.nodes.SpinnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_SWIFT3_OBJC_INFERENCE = On; - SWIFT_VERSION = 4.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -549,8 +553,8 @@ PRODUCT_BUNDLE_IDENTIFIER = dk.nodes.SpinnerTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_SWIFT3_OBJC_INFERENCE = On; - SWIFT_VERSION = 4.0; + SWIFT_SWIFT3_OBJC_INFERENCE = Default; + SWIFT_VERSION = 4.2; }; name = Release; }; @@ -575,7 +579,7 @@ SDKROOT = appletvos; SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; }; @@ -602,7 +606,7 @@ SDKROOT = appletvos; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.2; TARGETED_DEVICE_FAMILY = 3; TVOS_DEPLOYMENT_TARGET = 9.0; }; @@ -623,7 +627,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = appletvos; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.2; TVOS_DEPLOYMENT_TARGET = 10.0; }; name = Debug; @@ -643,7 +647,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SDKROOT = appletvos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.2; TVOS_DEPLOYMENT_TARGET = 10.0; }; name = Release; diff --git a/Spinner.xcodeproj/xcshareddata/xcschemes/Spinner-tvOS.xcscheme b/Spinner.xcodeproj/xcshareddata/xcschemes/Spinner-tvOS.xcscheme index 7ca7ad1..d97b3cd 100644 --- a/Spinner.xcodeproj/xcshareddata/xcschemes/Spinner-tvOS.xcscheme +++ b/Spinner.xcodeproj/xcshareddata/xcschemes/Spinner-tvOS.xcscheme @@ -1,6 +1,6 @@ SpinnerView { + public static func showSpinner(inView view: UIView, style: UIActivityIndicatorView.Style = .white, color:UIColor? = nil, disablesUserInteraction: Bool = true, dimBackground: Bool = false) -> SpinnerView { let center = CGPoint(x: view.bounds.size.width/2, y: view.bounds.size.height/2) - let activityIndicator = UIActivityIndicatorView(activityIndicatorStyle: style) + let activityIndicator = UIActivityIndicatorView(style: style) let spinnerView = SpinnerView() spinnerView.userInteractionEnabledAtReception = view.isUserInteractionEnabled @@ -99,7 +99,7 @@ public class SpinnerView: NSObject, Spinner { - Returns: A reference to the Spinner that was created, so that it can be dismissed as needed. */ - public static func showSpinner(inButton button: UIButton, style: UIActivityIndicatorViewStyle = .white, color:UIColor? = nil, disablesUserInteraction:Bool = true) -> SpinnerView { + public static func showSpinner(inButton button: UIButton, style: UIActivityIndicatorView.Style = .white, color:UIColor? = nil, disablesUserInteraction:Bool = true) -> SpinnerView { let spinnerView = showSpinner(inView: button, style: style, color: color) spinnerView.controlTitleColors = button.allTitleColors() @@ -257,7 +257,7 @@ fileprivate extension UIButton { // Extension to return an array of every color for every button state fileprivate func allTitleColors() -> [ControlTitleColor] { var colors: [ControlTitleColor] = [ - (UIControlState(), titleColor(for: UIControlState())), + (UIControl.State(), titleColor(for: UIControl.State())), (.highlighted, titleColor(for: .highlighted)), (.disabled, titleColor(for: .disabled)), (.selected, titleColor(for: .selected)), @@ -274,7 +274,7 @@ fileprivate extension UIButton { fileprivate func allTitleAttributes() -> [ControlTitleAttributes] { var attributes: [ControlTitleAttributes] = [ - (UIControlState(), attributedTitle(for: UIControlState())), + (UIControl.State(), attributedTitle(for: UIControl.State())), (.highlighted, attributedTitle(for: .highlighted)), (.disabled, attributedTitle(for: .disabled)), (.selected, attributedTitle(for: .selected)), diff --git a/SpinnerDemo/SpinnerDemo/SpinnerDemo.xcodeproj/project.pbxproj b/SpinnerDemo/SpinnerDemo/SpinnerDemo.xcodeproj/project.pbxproj index 085e099..7fa9990 100644 --- a/SpinnerDemo/SpinnerDemo/SpinnerDemo.xcodeproj/project.pbxproj +++ b/SpinnerDemo/SpinnerDemo/SpinnerDemo.xcodeproj/project.pbxproj @@ -199,7 +199,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0800; - LastUpgradeCheck = 0800; + LastUpgradeCheck = 1010; ORGANIZATIONNAME = Nodes; TargetAttributes = { D248C9551DAF8D4C003FD9F7 = { @@ -339,15 +339,24 @@ 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_DOCUMENTATION_COMMENTS = YES; 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_SUSPICIOUS_MOVES = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -389,15 +398,24 @@ 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_DOCUMENTATION_COMMENTS = YES; 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_SUSPICIOUS_MOVES = YES; CLANG_WARN_UNREACHABLE_CODE = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; @@ -432,7 +450,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.nodes.SpinnerDemo; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -445,7 +463,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.nodes.SpinnerDemo; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.2; }; name = Release; }; @@ -459,7 +477,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.nodes.SpinnerDemoTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.2; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SpinnerDemo.app/SpinnerDemo"; }; name = Debug; @@ -474,7 +492,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.nodes.SpinnerDemoTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.2; TEST_HOST = "$(BUILT_PRODUCTS_DIR)/SpinnerDemo.app/SpinnerDemo"; }; name = Release; @@ -488,7 +506,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.nodes.SpinnerDemoUITests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.2; TEST_TARGET_NAME = SpinnerDemo; }; name = Debug; @@ -502,7 +520,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.nodes.SpinnerDemoUITests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 3.0; + SWIFT_VERSION = 4.2; TEST_TARGET_NAME = SpinnerDemo; }; name = Release; diff --git a/SpinnerDemo/SpinnerDemo/SpinnerDemo/AppDelegate.swift b/SpinnerDemo/SpinnerDemo/SpinnerDemo/AppDelegate.swift index 4484e5b..081d947 100644 --- a/SpinnerDemo/SpinnerDemo/SpinnerDemo/AppDelegate.swift +++ b/SpinnerDemo/SpinnerDemo/SpinnerDemo/AppDelegate.swift @@ -14,7 +14,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application launch. return true } diff --git a/SpinnerTests/SpinnerTests.swift b/SpinnerTests/SpinnerTests.swift index a26bf0b..fd659c3 100644 --- a/SpinnerTests/SpinnerTests.swift +++ b/SpinnerTests/SpinnerTests.swift @@ -35,25 +35,25 @@ class SpinnerTests: XCTestCase { } func testDismissSpinnerInButton() { - button.setTitleColor(UIColor.red, for: UIControlState.normal) + button.setTitleColor(UIColor.red, for: UIControl.State.normal) let spinner = SpinnerView.showSpinner(inButton: button) spinner.dismiss() let hasSpinner = button.subviews.contains {$0 is Spinner} XCTAssertFalse(hasSpinner) XCTAssertTrue(button.isUserInteractionEnabled) - let titleColorRed = button.titleColor(for: UIControlState.normal) == UIColor.red + let titleColorRed = button.titleColor(for: UIControl.State.normal) == UIColor.red XCTAssertTrue(titleColorRed) } func testDismissSpinnerInButtonWithChangedColor() { - button.setTitleColor(UIColor.red, for: UIControlState.normal) + button.setTitleColor(UIColor.red, for: UIControl.State.normal) let spinner = SpinnerView.showSpinner(inButton: button) - button.setTitleColor(UIColor.blue, for: UIControlState.normal) + button.setTitleColor(UIColor.blue, for: UIControl.State.normal) spinner.dismiss() let hasSpinner = button.subviews.contains {$0 is Spinner} XCTAssertFalse(hasSpinner) XCTAssertTrue(button.isUserInteractionEnabled) - let titleColorBlue = button.titleColor(for: UIControlState.normal) == UIColor.blue + let titleColorBlue = button.titleColor(for: UIControl.State.normal) == UIColor.blue XCTAssertTrue(titleColorBlue) } @@ -153,7 +153,7 @@ class SpinnerTests: XCTestCase { func testShowSpinnerInButtonWithAttributedSting() { button.isUserInteractionEnabled = true - let attributedString = NSAttributedString(string: "title", attributes: [NSAttributedStringKey.font:UIFont.systemFont(ofSize: 19)]) + let attributedString = NSAttributedString(string: "title", attributes: [NSAttributedString.Key.font:UIFont.systemFont(ofSize: 19)]) button.setAttributedTitle(attributedString, for: .normal) let spinnerView = SpinnerView.showSpinner(inButton: button)