diff --git a/.travis.yml b/.travis.yml index ebd8151..4997cc4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,10 @@ language: objective-c -osx_image: xcode9 +osx_image: xcode10.2 env: - - ACTION=test PLATFORM=Mac DESTINATION='platform=OS X' + - ACTION=test PLATFORM=Mac DESTINATION='platform=macOS' - ACTION=test PLATFORM=iOS DESTINATION='platform=iOS Simulator,name=iPhone 6S' - - ACTION=test PLATFORM=tvOS DESTINATION='platform=tvOS Simulator,name=Apple TV 1080p' + - ACTION=test PLATFORM=tvOS DESTINATION='platform=tvOS Simulator,name=Apple TV 4K (at 1080p)' script: - set -o pipefail && xcodebuild -scheme SnapKit -destination "$DESTINATION" $ACTION | xcpretty diff --git a/SnapKit.podspec b/SnapKit.podspec index b55866a..d7d093d 100644 --- a/SnapKit.podspec +++ b/SnapKit.podspec @@ -14,5 +14,5 @@ Pod::Spec.new do |s| s.source_files = 'Source/*.swift' - s.swift_version = '4.2' + s.swift_version = '5.0' end diff --git a/SnapKit.xcodeproj/project.pbxproj b/SnapKit.xcodeproj/project.pbxproj index 0bd8d9e..53ab8b9 100644 --- a/SnapKit.xcodeproj/project.pbxproj +++ b/SnapKit.xcodeproj/project.pbxproj @@ -310,11 +310,11 @@ TargetAttributes = { EEBCC9D719CC627D0083B827 = { CreatedOnToolsVersion = 6.0; - LastSwiftMigration = 0900; + LastSwiftMigration = 1020; }; EEBCC9E119CC627D0083B827 = { CreatedOnToolsVersion = 6.0; - LastSwiftMigration = 0900; + LastSwiftMigration = 1020; ProvisioningStyle = Automatic; }; }; @@ -533,7 +533,7 @@ SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; }; name = Debug; @@ -553,7 +553,7 @@ PRODUCT_NAME = SnapKit; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.2; + SWIFT_VERSION = 5.0; VERSIONING_SYSTEM = "apple-generic"; }; name = Release; @@ -567,7 +567,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks @loader_path/../Frameworks @executable_path/../Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -581,7 +581,7 @@ PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Release; }; diff --git a/Source/Constraint.swift b/Source/Constraint.swift index 6e4948e..dc2c7c8 100644 --- a/Source/Constraint.swift +++ b/Source/Constraint.swift @@ -189,12 +189,12 @@ public final class Constraint { // MARK: Public - @available(*, deprecated:3.0, message:"Use activate().") + @available(*, deprecated, message:"Use activate().") public func install() { self.activate() } - @available(*, deprecated:3.0, message:"Use deactivate().") + @available(*, deprecated, message:"Use deactivate().") public func uninstall() { self.deactivate() } @@ -231,25 +231,25 @@ public final class Constraint { return self } - @available(*, deprecated:3.0, message:"Use update(offset: ConstraintOffsetTarget) instead.") + @available(*, deprecated, message:"Use update(offset: ConstraintOffsetTarget) instead.") public func updateOffset(amount: ConstraintOffsetTarget) -> Void { self.update(offset: amount) } - @available(*, deprecated:3.0, message:"Use update(inset: ConstraintInsetTarget) instead.") + @available(*, deprecated, message:"Use update(inset: ConstraintInsetTarget) instead.") public func updateInsets(amount: ConstraintInsetTarget) -> Void { self.update(inset: amount) } - @available(*, deprecated:3.0, message:"Use update(priority: ConstraintPriorityTarget) instead.") + @available(*, deprecated, message:"Use update(priority: ConstraintPriorityTarget) instead.") public func updatePriority(amount: ConstraintPriorityTarget) -> Void { self.update(priority: amount) } - @available(*, obsoleted:3.0, message:"Use update(priority: ConstraintPriorityTarget) instead.") + @available(*, deprecated, message:"Use update(priority: ConstraintPriorityTarget) instead.") public func updatePriorityRequired() -> Void {} - @available(*, obsoleted:3.0, message:"Use update(priority: ConstraintPriorityTarget) instead.") + @available(*, deprecated, message:"Use update(priority: ConstraintPriorityTarget) instead.") public func updatePriorityHigh() -> Void { fatalError("Must be implemented by Concrete subclass.") } - @available(*, obsoleted:3.0, message:"Use update(priority: ConstraintPriorityTarget) instead.") + @available(*, deprecated, message:"Use update(priority: ConstraintPriorityTarget) instead.") public func updatePriorityMedium() -> Void { fatalError("Must be implemented by Concrete subclass.") } - @available(*, obsoleted:3.0, message:"Use update(priority: ConstraintPriorityTarget) instead.") + @available(*, deprecated, message:"Use update(priority: ConstraintPriorityTarget) instead.") public func updatePriorityLow() -> Void { fatalError("Must be implemented by Concrete subclass.") } // MARK: Internal diff --git a/Source/ConstraintConstantTarget.swift b/Source/ConstraintConstantTarget.swift index bc6d596..7224df9 100644 --- a/Source/ConstraintConstantTarget.swift +++ b/Source/ConstraintConstantTarget.swift @@ -82,7 +82,11 @@ extension ConstraintConstantTarget { return value.y case .width, .height, .notAnAttribute: return 0.0 - } + #if swift(>=5.0) + @unknown default: + return 0.0 + #endif + } #else switch layoutAttribute { case .left, .right, .leading, .trailing, .centerX: @@ -91,7 +95,11 @@ extension ConstraintConstantTarget { return value.y case .width, .height, .notAnAttribute: return 0.0 - } + #if swift(>=5.0) + @unknown default: + return 0.0 + #endif + } #endif } @@ -116,7 +124,11 @@ extension ConstraintConstantTarget { return -(value.top + value.bottom) case .notAnAttribute: return 0.0 - } + #if swift(>=5.0) + @unknown default: + return 0.0 + #endif + } #else switch layoutAttribute { case .left, .centerX: @@ -137,7 +149,11 @@ extension ConstraintConstantTarget { return -(value.top + value.bottom) case .notAnAttribute: return 0.0 - } + #if swift(>=5.0) + @unknown default: + return 0.0 + #endif + } #endif } diff --git a/Source/ConstraintDSL.swift b/Source/ConstraintDSL.swift index a7e1798..b7aad57 100644 --- a/Source/ConstraintDSL.swift +++ b/Source/ConstraintDSL.swift @@ -115,7 +115,7 @@ extension ConstraintAttributesDSL { // MARK: Baselines - @available(*, deprecated:3.0, message:"Use .lastBaseline instead") + @available(*, deprecated, message:"Use .lastBaseline instead") public var baseline: ConstraintItem { return ConstraintItem(target: self.target, attributes: ConstraintAttributes.lastBaseline) } diff --git a/Source/ConstraintLayoutGuide+Extensions.swift b/Source/ConstraintLayoutGuide+Extensions.swift index c2d9e9d..d429e0c 100644 --- a/Source/ConstraintLayoutGuide+Extensions.swift +++ b/Source/ConstraintLayoutGuide+Extensions.swift @@ -29,7 +29,7 @@ @available(iOS 9.0, OSX 10.11, *) public extension ConstraintLayoutGuide { - public var snp: ConstraintLayoutGuideDSL { + var snp: ConstraintLayoutGuideDSL { return ConstraintLayoutGuideDSL(guide: self) } diff --git a/Source/ConstraintMaker.swift b/Source/ConstraintMaker.swift index 91f35f1..ed2879b 100644 --- a/Source/ConstraintMaker.swift +++ b/Source/ConstraintMaker.swift @@ -69,7 +69,7 @@ public class ConstraintMaker { return self.makeExtendableWithAttributes(.centerY) } - @available(*, deprecated:3.0, message:"Use lastBaseline instead") + @available(*, deprecated, message:"Use lastBaseline instead") public var baseline: ConstraintMakerExtendable { return self.makeExtendableWithAttributes(.lastBaseline) } diff --git a/Source/ConstraintMakerExtendable.swift b/Source/ConstraintMakerExtendable.swift index 6a755b5..243e54e 100644 --- a/Source/ConstraintMakerExtendable.swift +++ b/Source/ConstraintMakerExtendable.swift @@ -80,7 +80,7 @@ public class ConstraintMakerExtendable: ConstraintMakerRelatable { return self } - @available(*, deprecated:3.0, message:"Use lastBaseline instead") + @available(*, deprecated, message:"Use lastBaseline instead") public var baseline: ConstraintMakerExtendable { self.description.attributes += .lastBaseline return self diff --git a/Source/ConstraintMakerPriortizable.swift b/Source/ConstraintMakerPriortizable.swift index ef79448..e0d452d 100644 --- a/Source/ConstraintMakerPriortizable.swift +++ b/Source/ConstraintMakerPriortizable.swift @@ -42,25 +42,25 @@ public class ConstraintMakerPriortizable: ConstraintMakerFinalizable { return self } - @available(*, deprecated:3.0, message:"Use priority(.required) instead.") + @available(*, deprecated, message:"Use priority(.required) instead.") @discardableResult public func priorityRequired() -> ConstraintMakerFinalizable { return self.priority(.required) } - @available(*, deprecated:3.0, message:"Use priority(.high) instead.") + @available(*, deprecated, message:"Use priority(.high) instead.") @discardableResult public func priorityHigh() -> ConstraintMakerFinalizable { return self.priority(.high) } - @available(*, deprecated:3.0, message:"Use priority(.medium) instead.") + @available(*, deprecated, message:"Use priority(.medium) instead.") @discardableResult public func priorityMedium() -> ConstraintMakerFinalizable { return self.priority(.medium) } - @available(*, deprecated:3.0, message:"Use priority(.low) instead.") + @available(*, deprecated, message:"Use priority(.low) instead.") @discardableResult public func priorityLow() -> ConstraintMakerFinalizable { return self.priority(.low) diff --git a/Source/ConstraintView+Extensions.swift b/Source/ConstraintView+Extensions.swift index 77afad9..a4898dc 100644 --- a/Source/ConstraintView+Extensions.swift +++ b/Source/ConstraintView+Extensions.swift @@ -30,122 +30,122 @@ public extension ConstraintView { - @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") - public var snp_left: ConstraintItem { return self.snp.left } + @available(*, deprecated, message:"Use newer snp.* syntax.") + var snp_left: ConstraintItem { return self.snp.left } - @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") - public var snp_top: ConstraintItem { return self.snp.top } + @available(*, deprecated, message:"Use newer snp.* syntax.") + var snp_top: ConstraintItem { return self.snp.top } - @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") - public var snp_right: ConstraintItem { return self.snp.right } + @available(*, deprecated, message:"Use newer snp.* syntax.") + var snp_right: ConstraintItem { return self.snp.right } - @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") - public var snp_bottom: ConstraintItem { return self.snp.bottom } + @available(*, deprecated, message:"Use newer snp.* syntax.") + var snp_bottom: ConstraintItem { return self.snp.bottom } - @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") - public var snp_leading: ConstraintItem { return self.snp.leading } + @available(*, deprecated, message:"Use newer snp.* syntax.") + var snp_leading: ConstraintItem { return self.snp.leading } - @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") - public var snp_trailing: ConstraintItem { return self.snp.trailing } + @available(*, deprecated, message:"Use newer snp.* syntax.") + var snp_trailing: ConstraintItem { return self.snp.trailing } - @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") - public var snp_width: ConstraintItem { return self.snp.width } + @available(*, deprecated, message:"Use newer snp.* syntax.") + var snp_width: ConstraintItem { return self.snp.width } - @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") - public var snp_height: ConstraintItem { return self.snp.height } + @available(*, deprecated, message:"Use newer snp.* syntax.") + var snp_height: ConstraintItem { return self.snp.height } - @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") - public var snp_centerX: ConstraintItem { return self.snp.centerX } + @available(*, deprecated, message:"Use newer snp.* syntax.") + var snp_centerX: ConstraintItem { return self.snp.centerX } - @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") - public var snp_centerY: ConstraintItem { return self.snp.centerY } + @available(*, deprecated, message:"Use newer snp.* syntax.") + var snp_centerY: ConstraintItem { return self.snp.centerY } - @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") - public var snp_baseline: ConstraintItem { return self.snp.baseline } + @available(*, deprecated, message:"Use newer snp.* syntax.") + var snp_baseline: ConstraintItem { return self.snp.baseline } - @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") + @available(*, deprecated, message:"Use newer snp.* syntax.") @available(iOS 8.0, OSX 10.11, *) - public var snp_lastBaseline: ConstraintItem { return self.snp.lastBaseline } + var snp_lastBaseline: ConstraintItem { return self.snp.lastBaseline } - @available(iOS, deprecated:3.0, message:"Use newer snp.* syntax.") + @available(iOS, deprecated, message:"Use newer snp.* syntax.") @available(iOS 8.0, OSX 10.11, *) - public var snp_firstBaseline: ConstraintItem { return self.snp.firstBaseline } + var snp_firstBaseline: ConstraintItem { return self.snp.firstBaseline } - @available(iOS, deprecated:3.0, message:"Use newer snp.* syntax.") + @available(iOS, deprecated, message:"Use newer snp.* syntax.") @available(iOS 8.0, *) - public var snp_leftMargin: ConstraintItem { return self.snp.leftMargin } + var snp_leftMargin: ConstraintItem { return self.snp.leftMargin } - @available(iOS, deprecated:3.0, message:"Use newer snp.* syntax.") + @available(iOS, deprecated, message:"Use newer snp.* syntax.") @available(iOS 8.0, *) - public var snp_topMargin: ConstraintItem { return self.snp.topMargin } + var snp_topMargin: ConstraintItem { return self.snp.topMargin } - @available(iOS, deprecated:3.0, message:"Use newer snp.* syntax.") + @available(iOS, deprecated, message:"Use newer snp.* syntax.") @available(iOS 8.0, *) - public var snp_rightMargin: ConstraintItem { return self.snp.rightMargin } + var snp_rightMargin: ConstraintItem { return self.snp.rightMargin } - @available(iOS, deprecated:3.0, message:"Use newer snp.* syntax.") + @available(iOS, deprecated, message:"Use newer snp.* syntax.") @available(iOS 8.0, *) - public var snp_bottomMargin: ConstraintItem { return self.snp.bottomMargin } + var snp_bottomMargin: ConstraintItem { return self.snp.bottomMargin } - @available(iOS, deprecated:3.0, message:"Use newer snp.* syntax.") + @available(iOS, deprecated, message:"Use newer snp.* syntax.") @available(iOS 8.0, *) - public var snp_leadingMargin: ConstraintItem { return self.snp.leadingMargin } + var snp_leadingMargin: ConstraintItem { return self.snp.leadingMargin } - @available(iOS, deprecated:3.0, message:"Use newer snp.* syntax.") + @available(iOS, deprecated, message:"Use newer snp.* syntax.") @available(iOS 8.0, *) - public var snp_trailingMargin: ConstraintItem { return self.snp.trailingMargin } + var snp_trailingMargin: ConstraintItem { return self.snp.trailingMargin } - @available(iOS, deprecated:3.0, message:"Use newer snp.* syntax.") + @available(iOS, deprecated, message:"Use newer snp.* syntax.") @available(iOS 8.0, *) - public var snp_centerXWithinMargins: ConstraintItem { return self.snp.centerXWithinMargins } + var snp_centerXWithinMargins: ConstraintItem { return self.snp.centerXWithinMargins } - @available(iOS, deprecated:3.0, message:"Use newer snp.* syntax.") + @available(iOS, deprecated, message:"Use newer snp.* syntax.") @available(iOS 8.0, *) - public var snp_centerYWithinMargins: ConstraintItem { return self.snp.centerYWithinMargins } + var snp_centerYWithinMargins: ConstraintItem { return self.snp.centerYWithinMargins } - @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") - public var snp_edges: ConstraintItem { return self.snp.edges } + @available(*, deprecated, message:"Use newer snp.* syntax.") + var snp_edges: ConstraintItem { return self.snp.edges } - @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") - public var snp_size: ConstraintItem { return self.snp.size } + @available(*, deprecated, message:"Use newer snp.* syntax.") + var snp_size: ConstraintItem { return self.snp.size } - @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") - public var snp_center: ConstraintItem { return self.snp.center } + @available(*, deprecated, message:"Use newer snp.* syntax.") + var snp_center: ConstraintItem { return self.snp.center } - @available(iOS, deprecated:3.0, message:"Use newer snp.* syntax.") + @available(iOS, deprecated, message:"Use newer snp.* syntax.") @available(iOS 8.0, *) - public var snp_margins: ConstraintItem { return self.snp.margins } + var snp_margins: ConstraintItem { return self.snp.margins } - @available(iOS, deprecated:3.0, message:"Use newer snp.* syntax.") + @available(iOS, deprecated, message:"Use newer snp.* syntax.") @available(iOS 8.0, *) - public var snp_centerWithinMargins: ConstraintItem { return self.snp.centerWithinMargins } + var snp_centerWithinMargins: ConstraintItem { return self.snp.centerWithinMargins } - @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") - public func snp_prepareConstraints(_ closure: (_ make: ConstraintMaker) -> Void) -> [Constraint] { + @available(*, deprecated, message:"Use newer snp.* syntax.") + func snp_prepareConstraints(_ closure: (_ make: ConstraintMaker) -> Void) -> [Constraint] { return self.snp.prepareConstraints(closure) } - @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") - public func snp_makeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { + @available(*, deprecated, message:"Use newer snp.* syntax.") + func snp_makeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { self.snp.makeConstraints(closure) } - @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") - public func snp_remakeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { + @available(*, deprecated, message:"Use newer snp.* syntax.") + func snp_remakeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { self.snp.remakeConstraints(closure) } - @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") - public func snp_updateConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { + @available(*, deprecated, message:"Use newer snp.* syntax.") + func snp_updateConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { self.snp.updateConstraints(closure) } - @available(*, deprecated:3.0, message:"Use newer snp.* syntax.") - public func snp_removeConstraints() { + @available(*, deprecated, message:"Use newer snp.* syntax.") + func snp_removeConstraints() { self.snp.removeConstraints() } - public var snp: ConstraintViewDSL { + var snp: ConstraintViewDSL { return ConstraintViewDSL(view: self) } diff --git a/Source/Debugging.swift b/Source/Debugging.swift index 55f5b87..a78579a 100644 --- a/Source/Debugging.swift +++ b/Source/Debugging.swift @@ -29,7 +29,7 @@ public extension LayoutConstraint { - override public var description: String { + override var description: String { var description = "<" description += descriptionForObject(self) @@ -82,6 +82,9 @@ private func descriptionForRelation(_ relation: LayoutRelation) -> String { case .equal: return "==" case .greaterThanOrEqual: return ">=" case .lessThanOrEqual: return "<=" + #if swift(>=5.0) + @unknown default: return "unknown" + #endif } } @@ -109,7 +112,10 @@ private func descriptionForAttribute(_ attribute: LayoutAttribute) -> String { case .trailingMargin: return "trailingMargin" case .centerXWithinMargins: return "centerXWithinMargins" case .centerYWithinMargins: return "centerYWithinMargins" - } + #if swift(>=5.0) + @unknown default: return "unknown" + #endif + } #else switch attribute { case .notAnAttribute: return "notAnAttribute" @@ -125,7 +131,10 @@ private func descriptionForAttribute(_ attribute: LayoutAttribute) -> String { case .centerY: return "centerY" case .lastBaseline: return "lastBaseline" case .firstBaseline: return "firstBaseline" - } + #if swift(>=5.0) + @unknown default: return "unknown" + #endif + } #endif } diff --git a/Source/UILayoutSupport+Extensions.swift b/Source/UILayoutSupport+Extensions.swift index cfbce2e..8e7644c 100644 --- a/Source/UILayoutSupport+Extensions.swift +++ b/Source/UILayoutSupport+Extensions.swift @@ -29,7 +29,7 @@ @available(iOS 8.0, *) public extension ConstraintLayoutSupport { - public var snp: ConstraintLayoutSupportDSL { + var snp: ConstraintLayoutSupportDSL { return ConstraintLayoutSupportDSL(support: self) } diff --git a/Tests/SnapKitTests/Tests.swift b/Tests/SnapKitTests/Tests.swift index dd4a309..a4b587f 100644 --- a/Tests/SnapKitTests/Tests.swift +++ b/Tests/SnapKitTests/Tests.swift @@ -494,8 +494,8 @@ class SnapKitTests: XCTestCase { #if os(iOS) || os(tvOS) func testEdgesToMargins() { - var fromAttributes = Set() - var toAttributes = Set() + var fromAttributes = Set() + var toAttributes = Set() let view = View() self.container.addSubview(view)