Support swift 5.0 (#570)

* Update swift version 5.0

* Remove needless access control

* Fix misused "Available" annotations

* Support @unknown default

* Support swift 5.0 in test code

* Update podspec

* Update travis CI

* Code review by @freak4pc

* Add constraint for Swift version

* Fix build failed
This commit is contained in:
Jungwon An 2019-04-03 02:25:22 +09:00 committed by Robert Payne
parent 2f5a5da245
commit ca81e8ece0
14 changed files with 125 additions and 100 deletions

View File

@ -1,10 +1,10 @@
language: objective-c language: objective-c
osx_image: xcode9 osx_image: xcode10.2
env: 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=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: script:
- set -o pipefail && xcodebuild -scheme SnapKit -destination "$DESTINATION" $ACTION | xcpretty - set -o pipefail && xcodebuild -scheme SnapKit -destination "$DESTINATION" $ACTION | xcpretty

View File

@ -14,5 +14,5 @@ Pod::Spec.new do |s|
s.source_files = 'Source/*.swift' s.source_files = 'Source/*.swift'
s.swift_version = '4.2' s.swift_version = '5.0'
end end

View File

@ -310,11 +310,11 @@
TargetAttributes = { TargetAttributes = {
EEBCC9D719CC627D0083B827 = { EEBCC9D719CC627D0083B827 = {
CreatedOnToolsVersion = 6.0; CreatedOnToolsVersion = 6.0;
LastSwiftMigration = 0900; LastSwiftMigration = 1020;
}; };
EEBCC9E119CC627D0083B827 = { EEBCC9E119CC627D0083B827 = {
CreatedOnToolsVersion = 6.0; CreatedOnToolsVersion = 6.0;
LastSwiftMigration = 0900; LastSwiftMigration = 1020;
ProvisioningStyle = Automatic; ProvisioningStyle = Automatic;
}; };
}; };
@ -533,7 +533,7 @@
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone"; SWIFT_OPTIMIZATION_LEVEL = "-Onone";
SWIFT_VERSION = 4.2; SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic"; VERSIONING_SYSTEM = "apple-generic";
}; };
name = Debug; name = Debug;
@ -553,7 +553,7 @@
PRODUCT_NAME = SnapKit; PRODUCT_NAME = SnapKit;
SKIP_INSTALL = YES; SKIP_INSTALL = YES;
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.2; SWIFT_VERSION = 5.0;
VERSIONING_SYSTEM = "apple-generic"; VERSIONING_SYSTEM = "apple-generic";
}; };
name = Release; name = Release;
@ -567,7 +567,7 @@
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks @loader_path/../Frameworks @executable_path/../Frameworks"; 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_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 4.0; SWIFT_VERSION = 4.2;
}; };
name = Debug; name = Debug;
}; };
@ -581,7 +581,7 @@
PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)";
PRODUCT_NAME = "$(TARGET_NAME)"; PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
SWIFT_VERSION = 4.0; SWIFT_VERSION = 4.2;
}; };
name = Release; name = Release;
}; };

View File

@ -189,12 +189,12 @@ public final class Constraint {
// MARK: Public // MARK: Public
@available(*, deprecated:3.0, message:"Use activate().") @available(*, deprecated, message:"Use activate().")
public func install() { public func install() {
self.activate() self.activate()
} }
@available(*, deprecated:3.0, message:"Use deactivate().") @available(*, deprecated, message:"Use deactivate().")
public func uninstall() { public func uninstall() {
self.deactivate() self.deactivate()
} }
@ -231,25 +231,25 @@ public final class Constraint {
return self 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) } 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) } 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) } 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 {} 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.") } 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.") } 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.") } public func updatePriorityLow() -> Void { fatalError("Must be implemented by Concrete subclass.") }
// MARK: Internal // MARK: Internal

View File

@ -82,6 +82,10 @@ extension ConstraintConstantTarget {
return value.y return value.y
case .width, .height, .notAnAttribute: case .width, .height, .notAnAttribute:
return 0.0 return 0.0
#if swift(>=5.0)
@unknown default:
return 0.0
#endif
} }
#else #else
switch layoutAttribute { switch layoutAttribute {
@ -91,6 +95,10 @@ extension ConstraintConstantTarget {
return value.y return value.y
case .width, .height, .notAnAttribute: case .width, .height, .notAnAttribute:
return 0.0 return 0.0
#if swift(>=5.0)
@unknown default:
return 0.0
#endif
} }
#endif #endif
} }
@ -116,6 +124,10 @@ extension ConstraintConstantTarget {
return -(value.top + value.bottom) return -(value.top + value.bottom)
case .notAnAttribute: case .notAnAttribute:
return 0.0 return 0.0
#if swift(>=5.0)
@unknown default:
return 0.0
#endif
} }
#else #else
switch layoutAttribute { switch layoutAttribute {
@ -137,6 +149,10 @@ extension ConstraintConstantTarget {
return -(value.top + value.bottom) return -(value.top + value.bottom)
case .notAnAttribute: case .notAnAttribute:
return 0.0 return 0.0
#if swift(>=5.0)
@unknown default:
return 0.0
#endif
} }
#endif #endif
} }

View File

@ -115,7 +115,7 @@ extension ConstraintAttributesDSL {
// MARK: Baselines // MARK: Baselines
@available(*, deprecated:3.0, message:"Use .lastBaseline instead") @available(*, deprecated, message:"Use .lastBaseline instead")
public var baseline: ConstraintItem { public var baseline: ConstraintItem {
return ConstraintItem(target: self.target, attributes: ConstraintAttributes.lastBaseline) return ConstraintItem(target: self.target, attributes: ConstraintAttributes.lastBaseline)
} }

View File

@ -29,7 +29,7 @@
@available(iOS 9.0, OSX 10.11, *) @available(iOS 9.0, OSX 10.11, *)
public extension ConstraintLayoutGuide { public extension ConstraintLayoutGuide {
public var snp: ConstraintLayoutGuideDSL { var snp: ConstraintLayoutGuideDSL {
return ConstraintLayoutGuideDSL(guide: self) return ConstraintLayoutGuideDSL(guide: self)
} }

View File

@ -69,7 +69,7 @@ public class ConstraintMaker {
return self.makeExtendableWithAttributes(.centerY) return self.makeExtendableWithAttributes(.centerY)
} }
@available(*, deprecated:3.0, message:"Use lastBaseline instead") @available(*, deprecated, message:"Use lastBaseline instead")
public var baseline: ConstraintMakerExtendable { public var baseline: ConstraintMakerExtendable {
return self.makeExtendableWithAttributes(.lastBaseline) return self.makeExtendableWithAttributes(.lastBaseline)
} }

View File

@ -80,7 +80,7 @@ public class ConstraintMakerExtendable: ConstraintMakerRelatable {
return self return self
} }
@available(*, deprecated:3.0, message:"Use lastBaseline instead") @available(*, deprecated, message:"Use lastBaseline instead")
public var baseline: ConstraintMakerExtendable { public var baseline: ConstraintMakerExtendable {
self.description.attributes += .lastBaseline self.description.attributes += .lastBaseline
return self return self

View File

@ -42,25 +42,25 @@ public class ConstraintMakerPriortizable: ConstraintMakerFinalizable {
return self return self
} }
@available(*, deprecated:3.0, message:"Use priority(.required) instead.") @available(*, deprecated, message:"Use priority(.required) instead.")
@discardableResult @discardableResult
public func priorityRequired() -> ConstraintMakerFinalizable { public func priorityRequired() -> ConstraintMakerFinalizable {
return self.priority(.required) return self.priority(.required)
} }
@available(*, deprecated:3.0, message:"Use priority(.high) instead.") @available(*, deprecated, message:"Use priority(.high) instead.")
@discardableResult @discardableResult
public func priorityHigh() -> ConstraintMakerFinalizable { public func priorityHigh() -> ConstraintMakerFinalizable {
return self.priority(.high) return self.priority(.high)
} }
@available(*, deprecated:3.0, message:"Use priority(.medium) instead.") @available(*, deprecated, message:"Use priority(.medium) instead.")
@discardableResult @discardableResult
public func priorityMedium() -> ConstraintMakerFinalizable { public func priorityMedium() -> ConstraintMakerFinalizable {
return self.priority(.medium) return self.priority(.medium)
} }
@available(*, deprecated:3.0, message:"Use priority(.low) instead.") @available(*, deprecated, message:"Use priority(.low) instead.")
@discardableResult @discardableResult
public func priorityLow() -> ConstraintMakerFinalizable { public func priorityLow() -> ConstraintMakerFinalizable {
return self.priority(.low) return self.priority(.low)

View File

@ -30,122 +30,122 @@
public extension ConstraintView { public extension ConstraintView {
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.") @available(*, deprecated, message:"Use newer snp.* syntax.")
public var snp_left: ConstraintItem { return self.snp.left } var snp_left: ConstraintItem { return self.snp.left }
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.") @available(*, deprecated, message:"Use newer snp.* syntax.")
public var snp_top: ConstraintItem { return self.snp.top } var snp_top: ConstraintItem { return self.snp.top }
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.") @available(*, deprecated, message:"Use newer snp.* syntax.")
public var snp_right: ConstraintItem { return self.snp.right } var snp_right: ConstraintItem { return self.snp.right }
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.") @available(*, deprecated, message:"Use newer snp.* syntax.")
public var snp_bottom: ConstraintItem { return self.snp.bottom } var snp_bottom: ConstraintItem { return self.snp.bottom }
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.") @available(*, deprecated, message:"Use newer snp.* syntax.")
public var snp_leading: ConstraintItem { return self.snp.leading } var snp_leading: ConstraintItem { return self.snp.leading }
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.") @available(*, deprecated, message:"Use newer snp.* syntax.")
public var snp_trailing: ConstraintItem { return self.snp.trailing } var snp_trailing: ConstraintItem { return self.snp.trailing }
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.") @available(*, deprecated, message:"Use newer snp.* syntax.")
public var snp_width: ConstraintItem { return self.snp.width } var snp_width: ConstraintItem { return self.snp.width }
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.") @available(*, deprecated, message:"Use newer snp.* syntax.")
public var snp_height: ConstraintItem { return self.snp.height } var snp_height: ConstraintItem { return self.snp.height }
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.") @available(*, deprecated, message:"Use newer snp.* syntax.")
public var snp_centerX: ConstraintItem { return self.snp.centerX } var snp_centerX: ConstraintItem { return self.snp.centerX }
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.") @available(*, deprecated, message:"Use newer snp.* syntax.")
public var snp_centerY: ConstraintItem { return self.snp.centerY } var snp_centerY: ConstraintItem { return self.snp.centerY }
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.") @available(*, deprecated, message:"Use newer snp.* syntax.")
public var snp_baseline: ConstraintItem { return self.snp.baseline } 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, *) @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, *) @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, *) @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, *) @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, *) @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, *) @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, *) @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, *) @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, *) @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, *) @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.") @available(*, deprecated, message:"Use newer snp.* syntax.")
public var snp_edges: ConstraintItem { return self.snp.edges } var snp_edges: ConstraintItem { return self.snp.edges }
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.") @available(*, deprecated, message:"Use newer snp.* syntax.")
public var snp_size: ConstraintItem { return self.snp.size } var snp_size: ConstraintItem { return self.snp.size }
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.") @available(*, deprecated, message:"Use newer snp.* syntax.")
public var snp_center: ConstraintItem { return self.snp.center } 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, *) @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, *) @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.") @available(*, deprecated, message:"Use newer snp.* syntax.")
public func snp_prepareConstraints(_ closure: (_ make: ConstraintMaker) -> Void) -> [Constraint] { func snp_prepareConstraints(_ closure: (_ make: ConstraintMaker) -> Void) -> [Constraint] {
return self.snp.prepareConstraints(closure) return self.snp.prepareConstraints(closure)
} }
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.") @available(*, deprecated, message:"Use newer snp.* syntax.")
public func snp_makeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { func snp_makeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) {
self.snp.makeConstraints(closure) self.snp.makeConstraints(closure)
} }
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.") @available(*, deprecated, message:"Use newer snp.* syntax.")
public func snp_remakeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { func snp_remakeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) {
self.snp.remakeConstraints(closure) self.snp.remakeConstraints(closure)
} }
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.") @available(*, deprecated, message:"Use newer snp.* syntax.")
public func snp_updateConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { func snp_updateConstraints(_ closure: (_ make: ConstraintMaker) -> Void) {
self.snp.updateConstraints(closure) self.snp.updateConstraints(closure)
} }
@available(*, deprecated:3.0, message:"Use newer snp.* syntax.") @available(*, deprecated, message:"Use newer snp.* syntax.")
public func snp_removeConstraints() { func snp_removeConstraints() {
self.snp.removeConstraints() self.snp.removeConstraints()
} }
public var snp: ConstraintViewDSL { var snp: ConstraintViewDSL {
return ConstraintViewDSL(view: self) return ConstraintViewDSL(view: self)
} }

View File

@ -29,7 +29,7 @@
public extension LayoutConstraint { public extension LayoutConstraint {
override public var description: String { override var description: String {
var description = "<" var description = "<"
description += descriptionForObject(self) description += descriptionForObject(self)
@ -82,6 +82,9 @@ private func descriptionForRelation(_ relation: LayoutRelation) -> String {
case .equal: return "==" case .equal: return "=="
case .greaterThanOrEqual: return ">=" case .greaterThanOrEqual: return ">="
case .lessThanOrEqual: return "<=" case .lessThanOrEqual: return "<="
#if swift(>=5.0)
@unknown default: return "unknown"
#endif
} }
} }
@ -109,6 +112,9 @@ private func descriptionForAttribute(_ attribute: LayoutAttribute) -> String {
case .trailingMargin: return "trailingMargin" case .trailingMargin: return "trailingMargin"
case .centerXWithinMargins: return "centerXWithinMargins" case .centerXWithinMargins: return "centerXWithinMargins"
case .centerYWithinMargins: return "centerYWithinMargins" case .centerYWithinMargins: return "centerYWithinMargins"
#if swift(>=5.0)
@unknown default: return "unknown"
#endif
} }
#else #else
switch attribute { switch attribute {
@ -125,6 +131,9 @@ private func descriptionForAttribute(_ attribute: LayoutAttribute) -> String {
case .centerY: return "centerY" case .centerY: return "centerY"
case .lastBaseline: return "lastBaseline" case .lastBaseline: return "lastBaseline"
case .firstBaseline: return "firstBaseline" case .firstBaseline: return "firstBaseline"
#if swift(>=5.0)
@unknown default: return "unknown"
#endif
} }
#endif #endif
} }

View File

@ -29,7 +29,7 @@
@available(iOS 8.0, *) @available(iOS 8.0, *)
public extension ConstraintLayoutSupport { public extension ConstraintLayoutSupport {
public var snp: ConstraintLayoutSupportDSL { var snp: ConstraintLayoutSupportDSL {
return ConstraintLayoutSupportDSL(support: self) return ConstraintLayoutSupportDSL(support: self)
} }

View File

@ -494,8 +494,8 @@ class SnapKitTests: XCTestCase {
#if os(iOS) || os(tvOS) #if os(iOS) || os(tvOS)
func testEdgesToMargins() { func testEdgesToMargins() {
var fromAttributes = Set<NSLayoutAttribute>() var fromAttributes = Set<LayoutAttribute>()
var toAttributes = Set<NSLayoutAttribute>() var toAttributes = Set<LayoutAttribute>()
let view = View() let view = View()
self.container.addSubview(view) self.container.addSubview(view)