From a07ef8b04c65faacc74974b38b396b52e001a735 Mon Sep 17 00:00:00 2001 From: Benjamin Chrobot Date: Fri, 13 Oct 2017 05:32:30 -0400 Subject: [PATCH 01/57] Add support for UILayoutPriority as priority target. (#466) * Add support for UILayoutPriority as priority target. * Fixed for tvOS --- Source/ConstraintPriorityTarget.swift | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/Source/ConstraintPriorityTarget.swift b/Source/ConstraintPriorityTarget.swift index eb32f79..064f750 100644 --- a/Source/ConstraintPriorityTarget.swift +++ b/Source/ConstraintPriorityTarget.swift @@ -73,3 +73,13 @@ extension CGFloat: ConstraintPriorityTarget { } } + +#if os(iOS) || os(tvOS) +extension UILayoutPriority: ConstraintPriorityTarget { + + public var constraintPriorityTargetValue: Float { + return self.rawValue + } + +} +#endif From 2c8262ef9f00a250aae4f5f3c2a9539eb1c39520 Mon Sep 17 00:00:00 2001 From: Benjamin Chrobot Date: Fri, 13 Oct 2017 05:33:36 -0400 Subject: [PATCH 02/57] Add update(priority: ConstraintPriority) method (#467) * Add update(priority: ConstraintPriority) method * Fix copy-paste error --- Source/Constraint.swift | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Source/Constraint.swift b/Source/Constraint.swift index 2720745..0509f61 100644 --- a/Source/Constraint.swift +++ b/Source/Constraint.swift @@ -214,6 +214,12 @@ public final class Constraint { return self } + @discardableResult + public func update(priority: ConstraintPriority) -> Constraint { + self.priority = priority.value + return self + } + @available(*, deprecated:3.0, message:"Use update(offset: ConstraintOffsetTarget) instead.") public func updateOffset(amount: ConstraintOffsetTarget) -> Void { self.update(offset: amount) } From 01124b9f325dc48f72707b56781a82ad0b4174c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Sat, 19 May 2018 05:47:52 +0100 Subject: [PATCH 03/57] Add Swift Package Manager support (#501) --- .gitignore | 1 + Package.swift | 10 +++++++++- SnapKit.xcodeproj/project.pbxproj | 8 ++++---- Tests/{ => SnapKitTests}/Info.plist | 0 Tests/{ => SnapKitTests}/Tests.swift | 0 5 files changed, 14 insertions(+), 5 deletions(-) rename Tests/{ => SnapKitTests}/Info.plist (100%) rename Tests/{ => SnapKitTests}/Tests.swift (100%) diff --git a/.gitignore b/.gitignore index c0dbc2e..79fa0df 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +.build/ project.xcworkspace xcuserdata Examples/ diff --git a/Package.swift b/Package.swift index 2e87314..321d426 100644 --- a/Package.swift +++ b/Package.swift @@ -1,3 +1,4 @@ +// swift-tools-version:4.0 // // SnapKit // @@ -25,5 +26,12 @@ import PackageDescription let package = Package( - name: "SnapKit" + name: "SnapKit", + products: [ + .library(name: "SnapKit", targets: ["SnapKit"]), + ], + targets: [ + .target(name: "SnapKit", path: "Source"), + .testTarget(name: "SnapKitTests", dependencies: ["SnapKit"]), + ] ) diff --git a/SnapKit.xcodeproj/project.pbxproj b/SnapKit.xcodeproj/project.pbxproj index 58f9b93..b0193f2 100644 --- a/SnapKit.xcodeproj/project.pbxproj +++ b/SnapKit.xcodeproj/project.pbxproj @@ -82,8 +82,8 @@ EEBCC9E219CC627E0083B827 /* SnapKit Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SnapKit Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; EECDB3641AC0C95C006BBC11 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; EECDB3661AC0C95C006BBC11 /* SnapKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SnapKit.h; sourceTree = ""; }; - EECDB3691AC0C95C006BBC11 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - EECDB36A1AC0C95C006BBC11 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Tests.swift; sourceTree = ""; }; + EECDB3691AC0C95C006BBC11 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = SnapKitTests/Info.plist; sourceTree = ""; }; + EECDB36A1AC0C95C006BBC11 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Tests.swift; path = SnapKitTests/Tests.swift; sourceTree = ""; }; EEF68F9D1D78492400980C26 /* ConstraintLayoutGuideDSL.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintLayoutGuideDSL.swift; sourceTree = ""; }; EEF68FA51D784A5300980C26 /* ConstraintDSL.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintDSL.swift; sourceTree = ""; }; EEF68FAF1D784FB100980C26 /* ConstraintLayoutGuide+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ConstraintLayoutGuide+Extensions.swift"; sourceTree = ""; }; @@ -559,7 +559,7 @@ buildSettings = { "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; DEVELOPMENT_TEAM = ""; - INFOPLIST_FILE = "$(SRCROOT)/Tests/Info.plist"; + INFOPLIST_FILE = "$(SRCROOT)/Tests/SnapKitTests/Info.plist"; 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)"; @@ -572,7 +572,7 @@ buildSettings = { "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; DEVELOPMENT_TEAM = ""; - INFOPLIST_FILE = "$(SRCROOT)/Tests/Info.plist"; + INFOPLIST_FILE = "$(SRCROOT)/Tests/SnapKitTests/Info.plist"; 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)"; diff --git a/Tests/Info.plist b/Tests/SnapKitTests/Info.plist similarity index 100% rename from Tests/Info.plist rename to Tests/SnapKitTests/Info.plist diff --git a/Tests/Tests.swift b/Tests/SnapKitTests/Tests.swift similarity index 100% rename from Tests/Tests.swift rename to Tests/SnapKitTests/Tests.swift From 0503c24de8006fd6c94f91c74db09cda80af00c3 Mon Sep 17 00:00:00 2001 From: Mauro Vime Castillo Date: Mon, 11 Jun 2018 05:46:30 +0200 Subject: [PATCH 04/57] Swift4.2 (#516) --- Source/Typealiases.swift | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/Source/Typealiases.swift b/Source/Typealiases.swift index 8a44151..ded96cc 100644 --- a/Source/Typealiases.swift +++ b/Source/Typealiases.swift @@ -25,8 +25,13 @@ import Foundation #if os(iOS) || os(tvOS) import UIKit +#if swift(>=4.2) + typealias LayoutRelation = NSLayoutConstraint.Relation + typealias LayoutAttribute = NSLayoutConstraint.Attribute +#else typealias LayoutRelation = NSLayoutRelation typealias LayoutAttribute = NSLayoutAttribute +#endif typealias LayoutPriority = UILayoutPriority #else import AppKit From 163f5369d344ad2d8de2275c7aaab9ce6321cc3f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?o=28=EF=BF=A3=E3=81=B8=EF=BF=A3=29o?= Date: Sat, 23 Jun 2018 19:14:50 +0800 Subject: [PATCH 05/57] make ConstraintAttributes conform to ExpressibleByIntegerLiteral (#520) --- Source/ConstraintAttributes.swift | 63 +++++++++++++++++-------------- 1 file changed, 34 insertions(+), 29 deletions(-) diff --git a/Source/ConstraintAttributes.swift b/Source/ConstraintAttributes.swift index 10bddb1..5e2367e 100644 --- a/Source/ConstraintAttributes.swift +++ b/Source/ConstraintAttributes.swift @@ -28,7 +28,9 @@ #endif -internal struct ConstraintAttributes : OptionSet { +internal struct ConstraintAttributes : OptionSet, ExpressibleByIntegerLiteral { + + typealias IntegerLiteralType = UInt internal init(rawValue: UInt) { self.rawValue = rawValue @@ -39,10 +41,13 @@ internal struct ConstraintAttributes : OptionSet { internal init(nilLiteral: ()) { self.rawValue = 0 } + internal init(integerLiteral rawValue: IntegerLiteralType) { + self.init(rawValue: rawValue) + } internal private(set) var rawValue: UInt - internal static var allZeros: ConstraintAttributes { return self.init(0) } - internal static func convertFromNilLiteral() -> ConstraintAttributes { return self.init(0) } + internal static var allZeros: ConstraintAttributes { return 0 } + internal static func convertFromNilLiteral() -> ConstraintAttributes { return 0 } internal var boolValue: Bool { return self.rawValue != 0 } internal func toRaw() -> UInt { return self.rawValue } @@ -51,57 +56,57 @@ internal struct ConstraintAttributes : OptionSet { // normal - internal static var none: ConstraintAttributes { return self.init(0) } - internal static var left: ConstraintAttributes { return self.init(1) } - internal static var top: ConstraintAttributes { return self.init(2) } - internal static var right: ConstraintAttributes { return self.init(4) } - internal static var bottom: ConstraintAttributes { return self.init(8) } - internal static var leading: ConstraintAttributes { return self.init(16) } - internal static var trailing: ConstraintAttributes { return self.init(32) } - internal static var width: ConstraintAttributes { return self.init(64) } - internal static var height: ConstraintAttributes { return self.init(128) } - internal static var centerX: ConstraintAttributes { return self.init(256) } - internal static var centerY: ConstraintAttributes { return self.init(512) } - internal static var lastBaseline: ConstraintAttributes { return self.init(1024) } + internal static var none: ConstraintAttributes { return 0 } + internal static var left: ConstraintAttributes { return 1 } + internal static var top: ConstraintAttributes { return 2 } + internal static var right: ConstraintAttributes { return 4 } + internal static var bottom: ConstraintAttributes { return 8 } + internal static var leading: ConstraintAttributes { return 16 } + internal static var trailing: ConstraintAttributes { return 32 } + internal static var width: ConstraintAttributes { return 64 } + internal static var height: ConstraintAttributes { return 128 } + internal static var centerX: ConstraintAttributes { return 256 } + internal static var centerY: ConstraintAttributes { return 512 } + internal static var lastBaseline: ConstraintAttributes { return 1024 } @available(iOS 8.0, OSX 10.11, *) - internal static var firstBaseline: ConstraintAttributes { return self.init(2048) } + internal static var firstBaseline: ConstraintAttributes { return 2048 } @available(iOS 8.0, *) - internal static var leftMargin: ConstraintAttributes { return self.init(4096) } + internal static var leftMargin: ConstraintAttributes { return 4096 } @available(iOS 8.0, *) - internal static var rightMargin: ConstraintAttributes { return self.init(8192) } + internal static var rightMargin: ConstraintAttributes { return 8192 } @available(iOS 8.0, *) - internal static var topMargin: ConstraintAttributes { return self.init(16384) } + internal static var topMargin: ConstraintAttributes { return 16384 } @available(iOS 8.0, *) - internal static var bottomMargin: ConstraintAttributes { return self.init(32768) } + internal static var bottomMargin: ConstraintAttributes { return 32768 } @available(iOS 8.0, *) - internal static var leadingMargin: ConstraintAttributes { return self.init(65536) } + internal static var leadingMargin: ConstraintAttributes { return 65536 } @available(iOS 8.0, *) - internal static var trailingMargin: ConstraintAttributes { return self.init(131072) } + internal static var trailingMargin: ConstraintAttributes { return 131072 } @available(iOS 8.0, *) - internal static var centerXWithinMargins: ConstraintAttributes { return self.init(262144) } + internal static var centerXWithinMargins: ConstraintAttributes { return 262144 } @available(iOS 8.0, *) - internal static var centerYWithinMargins: ConstraintAttributes { return self.init(524288) } + internal static var centerYWithinMargins: ConstraintAttributes { return 524288 } // aggregates - internal static var edges: ConstraintAttributes { return self.init(15) } - internal static var size: ConstraintAttributes { return self.init(192) } - internal static var center: ConstraintAttributes { return self.init(768) } + internal static var edges: ConstraintAttributes { return 15 } + internal static var size: ConstraintAttributes { return 192 } + internal static var center: ConstraintAttributes { return 768 } @available(iOS 8.0, *) - internal static var margins: ConstraintAttributes { return self.init(61440) } + internal static var margins: ConstraintAttributes { return 61440 } @available(iOS 8.0, *) - internal static var centerWithinMargins: ConstraintAttributes { return self.init(786432) } + internal static var centerWithinMargins: ConstraintAttributes { return 786432 } internal var layoutAttributes:[LayoutAttribute] { var attrs = [LayoutAttribute]() From 15beb5221834e220f099a87beb80cc9d9abb16cf Mon Sep 17 00:00:00 2001 From: "Colin T.A. Gray" Date: Sat, 23 Jun 2018 05:15:34 -0600 Subject: [PATCH 06/57] Adds 'constraint.isActive = bool' to Constraint (#496) * delegate identical 'constraint creation' code to 'prepareConstraints' * adds 'set(isActivated:)' method to call appropriate 'activate/deactivate' based on bool cleans up about 30 lines of if foo { activate } else { deactivate } code in my app * instead of 'set(isActivated:)', use 'isActive = value' --- Source/Constraint.swift | 19 +++++++++++++++---- Source/ConstraintMaker.swift | 20 ++------------------ Tests/SnapKitTests/Tests.swift | 34 ++++++++++++++++++++++++++++++++++ 3 files changed, 51 insertions(+), 22 deletions(-) diff --git a/Source/Constraint.swift b/Source/Constraint.swift index 0509f61..6e4948e 100644 --- a/Source/Constraint.swift +++ b/Source/Constraint.swift @@ -49,12 +49,23 @@ public final class Constraint { public var layoutConstraints: [LayoutConstraint] public var isActive: Bool { - for layoutConstraint in self.layoutConstraints { - if layoutConstraint.isActive { - return true + set { + if newValue { + activate() + } + else { + deactivate() } } - return false + + get { + for layoutConstraint in self.layoutConstraints { + if layoutConstraint.isActive { + return true + } + } + return false + } } // MARK: Initialization diff --git a/Source/ConstraintMaker.swift b/Source/ConstraintMaker.swift index b20cdb5..91f35f1 100644 --- a/Source/ConstraintMaker.swift +++ b/Source/ConstraintMaker.swift @@ -171,15 +171,7 @@ public class ConstraintMaker { } internal static func makeConstraints(item: LayoutConstraintItem, closure: (_ make: ConstraintMaker) -> Void) { - let maker = ConstraintMaker(item: item) - closure(maker) - var constraints: [Constraint] = [] - for description in maker.descriptions { - guard let constraint = description.constraint else { - continue - } - constraints.append(constraint) - } + let constraints = prepareConstraints(item: item, closure: closure) for constraint in constraints { constraint.activateIfNeeded(updatingExisting: false) } @@ -196,15 +188,7 @@ public class ConstraintMaker { return } - let maker = ConstraintMaker(item: item) - closure(maker) - var constraints: [Constraint] = [] - for description in maker.descriptions { - guard let constraint = description.constraint else { - continue - } - constraints.append(constraint) - } + let constraints = prepareConstraints(item: item, closure: closure) for constraint in constraints { constraint.activateIfNeeded(updatingExisting: true) } diff --git a/Tests/SnapKitTests/Tests.swift b/Tests/SnapKitTests/Tests.swift index db414ff..dd4a309 100644 --- a/Tests/SnapKitTests/Tests.swift +++ b/Tests/SnapKitTests/Tests.swift @@ -264,6 +264,40 @@ class SnapKitTests: XCTestCase { } + func testSetIsActivatedConstraints() { + let v1 = View() + let v2 = View() + self.container.addSubview(v1) + self.container.addSubview(v2) + + var c1: Constraint? = nil + var c2: Constraint? = nil + + v1.snp.prepareConstraints { (make) -> Void in + c1 = make.top.equalTo(v2.snp.top).offset(50).constraint + c2 = make.left.equalTo(v2.snp.top).offset(50).constraint + return + } + + XCTAssertEqual(self.container.snp_constraints.count, 0, "Should have 0 constraints") + + c1?.isActive = true + c2?.isActive = false + + XCTAssertEqual(self.container.snp_constraints.count, 1, "Should have 1 constraint") + + c1?.isActive = true + c2?.isActive = true + + XCTAssertEqual(self.container.snp_constraints.count, 2, "Should have 2 constraints") + + c1?.isActive = false + c2?.isActive = false + + XCTAssertEqual(self.container.snp_constraints.count, 0, "Should have 0 constraints") + + } + func testEdgeConstraints() { let view = View() self.container.addSubview(view) From 7ec06634be260c8b4b02cc289cff8f1736c2f1be Mon Sep 17 00:00:00 2001 From: Robert Payne Date: Tue, 18 Sep 2018 15:43:30 +1200 Subject: [PATCH 07/57] Add swift version to podspec --- SnapKit.podspec | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/SnapKit.podspec b/SnapKit.podspec index 7b50368..702705d 100644 --- a/SnapKit.podspec +++ b/SnapKit.podspec @@ -6,7 +6,7 @@ Pod::Spec.new do |s| s.homepage = 'https://github.com/SnapKit/SnapKit' s.authors = { 'Robert Payne' => 'robertpayne@me.com' } s.social_media_url = 'http://twitter.com/robertjpayne' - s.source = { :git => 'https://github.com/SnapKit/SnapKit.git', :tag => '4.0.0' } + s.source = { :git => 'https://github.com/SnapKit/SnapKit.git', :tag => '4.0.1' } s.ios.deployment_target = '8.0' s.osx.deployment_target = '10.11' @@ -14,5 +14,7 @@ Pod::Spec.new do |s| s.source_files = 'Source/*.swift' + s.swift_version = '4.0' + s.requires_arc = true end From fdcd3da2bb2d0a726ce3d09d23f48b5bf7069368 Mon Sep 17 00:00:00 2001 From: Robert Payne Date: Tue, 18 Sep 2018 16:05:09 +1200 Subject: [PATCH 08/57] Update podspec --- SnapKit.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SnapKit.podspec b/SnapKit.podspec index 702705d..9e25579 100644 --- a/SnapKit.podspec +++ b/SnapKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'SnapKit' - s.version = '4.0.0' + s.version = '4.0.1' s.license = 'MIT' s.summary = 'Harness the power of auto layout with a simplified, chainable, and compile time safe syntax.' s.homepage = 'https://github.com/SnapKit/SnapKit' From 0c92c7a9a90ee7a9c71f95f400f86e0d611f757f Mon Sep 17 00:00:00 2001 From: Robert Payne Date: Tue, 18 Sep 2018 16:39:42 +1200 Subject: [PATCH 09/57] Update podspec --- SnapKit.podspec | 2 -- 1 file changed, 2 deletions(-) diff --git a/SnapKit.podspec b/SnapKit.podspec index 9e25579..c4daf0f 100644 --- a/SnapKit.podspec +++ b/SnapKit.podspec @@ -15,6 +15,4 @@ Pod::Spec.new do |s| s.source_files = 'Source/*.swift' s.swift_version = '4.0' - - s.requires_arc = true end From 6af44ff4c901df25c06e12651bec9a3a56dce0a5 Mon Sep 17 00:00:00 2001 From: Shai Mishali Date: Sat, 29 Sep 2018 12:28:33 +0300 Subject: [PATCH 10/57] Update project to get rid of Migration Warning (#547) --- SnapKit.xcodeproj/project.pbxproj | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/SnapKit.xcodeproj/project.pbxproj b/SnapKit.xcodeproj/project.pbxproj index b0193f2..ff6ea50 100644 --- a/SnapKit.xcodeproj/project.pbxproj +++ b/SnapKit.xcodeproj/project.pbxproj @@ -305,7 +305,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0720; - LastUpgradeCheck = 0900; + LastUpgradeCheck = 1000; ORGANIZATIONNAME = "SnapKit Team"; TargetAttributes = { EEBCC9D719CC627D0083B827 = { @@ -420,12 +420,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; @@ -477,12 +479,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; From 460a6c524f906570e84b2da1891d00c6e69ee08d Mon Sep 17 00:00:00 2001 From: Ibrahim Koteish Date: Mon, 22 Oct 2018 14:48:31 +0300 Subject: [PATCH 11/57] Update Swift Language version to 4.2 under build settings (#551) * Update swift language version to 4.2 in build settings * Update podspec --- SnapKit.podspec | 2 +- SnapKit.xcodeproj/project.pbxproj | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/SnapKit.podspec b/SnapKit.podspec index c4daf0f..da77d69 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.0' + s.swift_version = '4.2' end diff --git a/SnapKit.xcodeproj/project.pbxproj b/SnapKit.xcodeproj/project.pbxproj index ff6ea50..0bd8d9e 100644 --- a/SnapKit.xcodeproj/project.pbxproj +++ b/SnapKit.xcodeproj/project.pbxproj @@ -533,7 +533,7 @@ SKIP_INSTALL = YES; SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; VERSIONING_SYSTEM = "apple-generic"; }; name = Debug; @@ -553,7 +553,7 @@ PRODUCT_NAME = SnapKit; SKIP_INSTALL = YES; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; VERSIONING_SYSTEM = "apple-generic"; }; name = Release; From 8f9aaea2724630c576a1125f0d0112cbaf4335ad Mon Sep 17 00:00:00 2001 From: Robert Payne Date: Tue, 23 Oct 2018 00:52:46 +1300 Subject: [PATCH 12/57] Remove Swift Version file --- .swift-version | 1 - 1 file changed, 1 deletion(-) delete mode 100644 .swift-version diff --git a/.swift-version b/.swift-version deleted file mode 100644 index 389f774..0000000 --- a/.swift-version +++ /dev/null @@ -1 +0,0 @@ -4.0 \ No newline at end of file From 477fffae4c37386285f78511ff4120f1f5324ff8 Mon Sep 17 00:00:00 2001 From: Robert Payne Date: Tue, 23 Oct 2018 00:53:40 +1300 Subject: [PATCH 13/57] Remove Package.swift, SnapKit is not SwiftPM compatible anyways --- Package.swift | 37 ------------------------------------- 1 file changed, 37 deletions(-) delete mode 100644 Package.swift diff --git a/Package.swift b/Package.swift deleted file mode 100644 index 321d426..0000000 --- a/Package.swift +++ /dev/null @@ -1,37 +0,0 @@ -// swift-tools-version:4.0 -// -// SnapKit -// -// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - - -import PackageDescription - -let package = Package( - name: "SnapKit", - products: [ - .library(name: "SnapKit", targets: ["SnapKit"]), - ], - targets: [ - .target(name: "SnapKit", path: "Source"), - .testTarget(name: "SnapKitTests", dependencies: ["SnapKit"]), - ] -) From 066be5492b431bc7f73a51c4a2ef872cf14ca1eb Mon Sep 17 00:00:00 2001 From: Robert Payne Date: Tue, 23 Oct 2018 00:53:44 +1300 Subject: [PATCH 14/57] Update Podspec --- SnapKit.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SnapKit.podspec b/SnapKit.podspec index da77d69..a9a181d 100644 --- a/SnapKit.podspec +++ b/SnapKit.podspec @@ -6,7 +6,7 @@ Pod::Spec.new do |s| s.homepage = 'https://github.com/SnapKit/SnapKit' s.authors = { 'Robert Payne' => 'robertpayne@me.com' } s.social_media_url = 'http://twitter.com/robertjpayne' - s.source = { :git => 'https://github.com/SnapKit/SnapKit.git', :tag => '4.0.1' } + s.source = { :git => 'https://github.com/SnapKit/SnapKit.git', :tag => '4.2.0' } s.ios.deployment_target = '8.0' s.osx.deployment_target = '10.11' From 2f5a5da2458a4ae0fcd7d4a27e98a54d7f235af1 Mon Sep 17 00:00:00 2001 From: Robert Payne Date: Tue, 23 Oct 2018 01:15:28 +1300 Subject: [PATCH 15/57] Update version in Podspec --- SnapKit.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SnapKit.podspec b/SnapKit.podspec index a9a181d..b55866a 100644 --- a/SnapKit.podspec +++ b/SnapKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'SnapKit' - s.version = '4.0.1' + s.version = '4.2.0' s.license = 'MIT' s.summary = 'Harness the power of auto layout with a simplified, chainable, and compile time safe syntax.' s.homepage = 'https://github.com/SnapKit/SnapKit' From ca81e8ece0f043889151f7c6e406fc2fd7fd6526 Mon Sep 17 00:00:00 2001 From: Jungwon An Date: Wed, 3 Apr 2019 02:25:22 +0900 Subject: [PATCH 16/57] 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 --- .travis.yml | 6 +- SnapKit.podspec | 2 +- SnapKit.xcodeproj/project.pbxproj | 12 +- Source/Constraint.swift | 18 +-- Source/ConstraintConstantTarget.swift | 24 +++- Source/ConstraintDSL.swift | 2 +- Source/ConstraintLayoutGuide+Extensions.swift | 2 +- Source/ConstraintMaker.swift | 2 +- Source/ConstraintMakerExtendable.swift | 2 +- Source/ConstraintMakerPriortizable.swift | 8 +- Source/ConstraintView+Extensions.swift | 126 +++++++++--------- Source/Debugging.swift | 15 ++- Source/UILayoutSupport+Extensions.swift | 2 +- Tests/SnapKitTests/Tests.swift | 4 +- 14 files changed, 125 insertions(+), 100 deletions(-) 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) From bc2b0b93320513eb747b3baf6332c05bacc067b4 Mon Sep 17 00:00:00 2001 From: Alexander Belonogov Date: Tue, 2 Apr 2019 19:28:51 +0200 Subject: [PATCH 17/57] [EXC_BAD_ACCESS] Update LayoutConstraint == operator to support iOS 10 and higher changes (#574) * @sashabelonogov Update LayoutConstraint == operator to support iOS 10 and higher changes * Simplify return statement of the LayoutConstraint == operator --- Source/LayoutConstraint.swift | 22 +++++++++++++--------- Tests/SnapKitTests/Tests.swift | 30 ++++++++++++++++++++++++++++++ 2 files changed, 43 insertions(+), 9 deletions(-) diff --git a/Source/LayoutConstraint.swift b/Source/LayoutConstraint.swift index 8bb5ed2..91fad77 100644 --- a/Source/LayoutConstraint.swift +++ b/Source/LayoutConstraint.swift @@ -44,14 +44,18 @@ public class LayoutConstraint : NSLayoutConstraint { } internal func ==(lhs: LayoutConstraint, rhs: LayoutConstraint) -> Bool { - guard lhs.firstItem === rhs.firstItem && - lhs.secondItem === rhs.secondItem && - lhs.firstAttribute == rhs.firstAttribute && - lhs.secondAttribute == rhs.secondAttribute && - lhs.relation == rhs.relation && - lhs.priority == rhs.priority && - lhs.multiplier == rhs.multiplier else { - return false + let areLayoutAnchorsEqual: Bool + if #available(iOS 10.0, OSXApplicationExtension 10.12, *) { + areLayoutAnchorsEqual = lhs.firstAnchor === rhs.firstAnchor && + lhs.secondAnchor === rhs.secondAnchor + } else { + areLayoutAnchorsEqual = lhs.firstItem === rhs.firstItem && + lhs.secondItem === rhs.secondItem && + lhs.firstAttribute == rhs.firstAttribute && + lhs.secondAttribute == rhs.secondAttribute } - return true + return areLayoutAnchorsEqual && + lhs.relation == rhs.relation && + lhs.priority == rhs.priority && + lhs.multiplier == rhs.multiplier } diff --git a/Tests/SnapKitTests/Tests.swift b/Tests/SnapKitTests/Tests.swift index a4b587f..7a46b2e 100644 --- a/Tests/SnapKitTests/Tests.swift +++ b/Tests/SnapKitTests/Tests.swift @@ -580,4 +580,34 @@ class SnapKitTests: XCTestCase { let higherPriority: ConstraintPriority = ConstraintPriority.high.advanced(by: 1) XCTAssertEqual(higherPriority.value, highPriority.value + 1) } + + func testLayoutConstraintEqual() { + let view1 = View() + let view2 = View() + let layoutConstraint1 = LayoutConstraint(item: view1, + attribute: .top, + relatedBy: .lessThanOrEqual, + toItem: view2, + attribute: .bottom, + multiplier: 2, + constant: 30) + let layoutConstraint2 = LayoutConstraint(item: view1, + attribute: .top, + relatedBy: .lessThanOrEqual, + toItem: view2, + attribute: .bottom, + multiplier: 2, + constant: 30) + let layoutConstraint3 = LayoutConstraint(item: view1, + attribute: .top, + relatedBy: .lessThanOrEqual, + toItem: view2, + attribute: .bottom, + multiplier: 1, + constant: 50) + XCTAssertTrue(layoutConstraint1 == layoutConstraint2) + XCTAssertFalse(layoutConstraint1 == layoutConstraint3) + XCTAssertFalse(layoutConstraint2 == layoutConstraint3) + } + } From b3b64f61a74572bab2c36eced63f954f3a71e587 Mon Sep 17 00:00:00 2001 From: Christian Schnorr Date: Tue, 2 Apr 2019 19:31:01 +0200 Subject: [PATCH 18/57] Fix incorrect behavior of inset with center and baseline anchors (#569) * Fix insets adjusting center attributes incorrectly * Fix insets adjusting baseline attributes incorrectly --- Source/ConstraintConstantTarget.swift | 20 ++++++++++++++------ 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/Source/ConstraintConstantTarget.swift b/Source/ConstraintConstantTarget.swift index 7224df9..24052ae 100644 --- a/Source/ConstraintConstantTarget.swift +++ b/Source/ConstraintConstantTarget.swift @@ -106,18 +106,22 @@ extension ConstraintConstantTarget { if let value = self as? ConstraintInsets { #if os(iOS) || os(tvOS) switch layoutAttribute { - case .left, .leftMargin, .centerX, .centerXWithinMargins: + case .left, .leftMargin: return value.left - case .top, .topMargin, .centerY, .centerYWithinMargins, .lastBaseline, .firstBaseline: + case .top, .topMargin, .firstBaseline: return value.top case .right, .rightMargin: return -value.right - case .bottom, .bottomMargin: + case .bottom, .bottomMargin, .lastBaseline: return -value.bottom case .leading, .leadingMargin: return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? value.left : value.right case .trailing, .trailingMargin: return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? -value.right : -value.left + case .centerX, .centerXWithinMargins: + return (value.left - value.right) / 2 + case .centerY, .centerYWithinMargins: + return (value.top - value.bottom) / 2 case .width: return -(value.left + value.right) case .height: @@ -131,18 +135,22 @@ extension ConstraintConstantTarget { } #else switch layoutAttribute { - case .left, .centerX: + case .left: return value.left - case .top, .centerY, .lastBaseline, .firstBaseline: + case .top, .firstBaseline: return value.top case .right: return -value.right - case .bottom: + case .bottom, .lastBaseline: return -value.bottom case .leading: return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? value.left : value.right case .trailing: return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? -value.right : -value.left + case .centerX: + return (value.left - value.right) / 2 + case .centerY: + return (value.top - value.bottom) / 2 case .width: return -(value.left + value.right) case .height: From eea05d74f073696202cd0bb8e744e4c89781a414 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Linus=20Unneb=C3=A4ck?= Date: Wed, 3 Apr 2019 12:45:05 +0100 Subject: [PATCH 19/57] Add back Package.swift for SwiftPM compatibility (#559) reverts 477fffae4c37386285f78511ff4120f1f5324ff8 --- Package.swift | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 Package.swift diff --git a/Package.swift b/Package.swift new file mode 100644 index 0000000..865eabf --- /dev/null +++ b/Package.swift @@ -0,0 +1,37 @@ +// swift-tools-version:5.0 +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + + +import PackageDescription + +let package = Package( + name: "SnapKit", + products: [ + .library(name: "SnapKit", targets: ["SnapKit"]), + ], + targets: [ + .target(name: "SnapKit", path: "Source"), + .testTarget(name: "SnapKitTests", dependencies: ["SnapKit"]), + ] +) From 5ac6af76c25f1f5541ef2ff223b552ad0e984133 Mon Sep 17 00:00:00 2001 From: Robert Payne Date: Tue, 23 Apr 2019 22:47:08 +1200 Subject: [PATCH 20/57] Update podspec --- SnapKit.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SnapKit.podspec b/SnapKit.podspec index d7d093d..167c11c 100644 --- a/SnapKit.podspec +++ b/SnapKit.podspec @@ -1,12 +1,12 @@ Pod::Spec.new do |s| s.name = 'SnapKit' - s.version = '4.2.0' + s.version = '5.0.0' s.license = 'MIT' s.summary = 'Harness the power of auto layout with a simplified, chainable, and compile time safe syntax.' s.homepage = 'https://github.com/SnapKit/SnapKit' s.authors = { 'Robert Payne' => 'robertpayne@me.com' } s.social_media_url = 'http://twitter.com/robertjpayne' - s.source = { :git => 'https://github.com/SnapKit/SnapKit.git', :tag => '4.2.0' } + s.source = { :git => 'https://github.com/SnapKit/SnapKit.git', :tag => '5.0.0' } s.ios.deployment_target = '8.0' s.osx.deployment_target = '10.11' From 4403a45695111f4b575f62d9cb689e502b429ad9 Mon Sep 17 00:00:00 2001 From: Robert Payne Date: Tue, 23 Apr 2019 22:59:46 +1200 Subject: [PATCH 21/57] Update min target versions --- SnapKit.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SnapKit.podspec b/SnapKit.podspec index 167c11c..5c73581 100644 --- a/SnapKit.podspec +++ b/SnapKit.podspec @@ -8,8 +8,8 @@ Pod::Spec.new do |s| s.social_media_url = 'http://twitter.com/robertjpayne' s.source = { :git => 'https://github.com/SnapKit/SnapKit.git', :tag => '5.0.0' } - s.ios.deployment_target = '8.0' - s.osx.deployment_target = '10.11' + s.ios.deployment_target = '9.0' + s.osx.deployment_target = '10.12' s.tvos.deployment_target = '9.0' s.source_files = 'Source/*.swift' From 328b53b7e3d3d0f32d03adaf7c84297a7310cdf5 Mon Sep 17 00:00:00 2001 From: Robert Payne Date: Tue, 23 Apr 2019 23:01:11 +1200 Subject: [PATCH 22/57] Update min target versions --- SnapKit.podspec | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/SnapKit.podspec b/SnapKit.podspec index 5c73581..e0c5df3 100644 --- a/SnapKit.podspec +++ b/SnapKit.podspec @@ -8,9 +8,9 @@ Pod::Spec.new do |s| s.social_media_url = 'http://twitter.com/robertjpayne' s.source = { :git => 'https://github.com/SnapKit/SnapKit.git', :tag => '5.0.0' } - s.ios.deployment_target = '9.0' + s.ios.deployment_target = '10.0' s.osx.deployment_target = '10.12' - s.tvos.deployment_target = '9.0' + s.tvos.deployment_target = '10.0' s.source_files = 'Source/*.swift' From 74f684b3eb1159a7624a77e8db96f9ed3528b5b5 Mon Sep 17 00:00:00 2001 From: Robert Payne Date: Thu, 25 Apr 2019 12:44:47 +1200 Subject: [PATCH 23/57] Update README.md --- README.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index fed2133..cb0352a 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,8 @@ SnapKit is a DSL to make Auto Layout easy on both iOS and OS X. [![Cocoapods Compatible](https://img.shields.io/cocoapods/v/SnapKit.svg)](https://cocoapods.org/pods/SnapKit) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) -#### ⚠️ **To use with Swift 3.x please ensure you are using >= 3.0.0** ⚠️ #### ⚠️ **To use with Swift 4.x please ensure you are using >= 4.0.0** ⚠️ +#### ⚠️ **To use with Swift 5.x please ensure you are using >= 5.0.0** ⚠️ ## Contents @@ -22,9 +22,9 @@ SnapKit is a DSL to make Auto Layout easy on both iOS and OS X. ## Requirements -- iOS 8.0+ / Mac OS X 10.11+ / tvOS 9.0+ +- iOS 10.0+ / Mac OS X 10.12+ / tvOS 10.0+ - Xcode 9.0+ -- Swift 3.0+ +- Swift 4.0+ ## Communication @@ -55,7 +55,7 @@ platform :ios, '10.0' use_frameworks! target '' do - pod 'SnapKit', '~> 4.0.0' + pod 'SnapKit', '~> 5.0.0' end ``` @@ -79,7 +79,7 @@ $ brew install carthage To integrate SnapKit into your Xcode project using Carthage, specify it in your `Cartfile`: ```ogdl -github "SnapKit/SnapKit" ~> 4.0.0 +github "SnapKit/SnapKit" ~> 5.0.0 ``` Run `carthage update` to build the framework and drag the built `SnapKit.framework` into your Xcode project. From e9b237468b4835a30889e72b3ec5e431ade6edff Mon Sep 17 00:00:00 2001 From: Robert Payne Date: Thu, 25 Apr 2019 12:45:13 +1200 Subject: [PATCH 24/57] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cb0352a..32b6518 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ SnapKit is a DSL to make Auto Layout easy on both iOS and OS X. ## Requirements - iOS 10.0+ / Mac OS X 10.12+ / tvOS 10.0+ -- Xcode 9.0+ +- Xcode 10.0+ - Swift 4.0+ ## Communication From f59340c39b9c5763b9b5b06cc750c7f95f4e34c6 Mon Sep 17 00:00:00 2001 From: Robert Payne Date: Sun, 28 Apr 2019 20:43:09 +1200 Subject: [PATCH 25/57] Revert "[EXC_BAD_ACCESS] Update LayoutConstraint == operator to support iOS 10 and higher changes (#574)" (#593) This reverts commit bc2b0b93320513eb747b3baf6332c05bacc067b4. --- Source/LayoutConstraint.swift | 22 +++++++++------------- Tests/SnapKitTests/Tests.swift | 30 ------------------------------ 2 files changed, 9 insertions(+), 43 deletions(-) diff --git a/Source/LayoutConstraint.swift b/Source/LayoutConstraint.swift index 91fad77..8bb5ed2 100644 --- a/Source/LayoutConstraint.swift +++ b/Source/LayoutConstraint.swift @@ -44,18 +44,14 @@ public class LayoutConstraint : NSLayoutConstraint { } internal func ==(lhs: LayoutConstraint, rhs: LayoutConstraint) -> Bool { - let areLayoutAnchorsEqual: Bool - if #available(iOS 10.0, OSXApplicationExtension 10.12, *) { - areLayoutAnchorsEqual = lhs.firstAnchor === rhs.firstAnchor && - lhs.secondAnchor === rhs.secondAnchor - } else { - areLayoutAnchorsEqual = lhs.firstItem === rhs.firstItem && - lhs.secondItem === rhs.secondItem && - lhs.firstAttribute == rhs.firstAttribute && - lhs.secondAttribute == rhs.secondAttribute + guard lhs.firstItem === rhs.firstItem && + lhs.secondItem === rhs.secondItem && + lhs.firstAttribute == rhs.firstAttribute && + lhs.secondAttribute == rhs.secondAttribute && + lhs.relation == rhs.relation && + lhs.priority == rhs.priority && + lhs.multiplier == rhs.multiplier else { + return false } - return areLayoutAnchorsEqual && - lhs.relation == rhs.relation && - lhs.priority == rhs.priority && - lhs.multiplier == rhs.multiplier + return true } diff --git a/Tests/SnapKitTests/Tests.swift b/Tests/SnapKitTests/Tests.swift index 7a46b2e..a4b587f 100644 --- a/Tests/SnapKitTests/Tests.swift +++ b/Tests/SnapKitTests/Tests.swift @@ -580,34 +580,4 @@ class SnapKitTests: XCTestCase { let higherPriority: ConstraintPriority = ConstraintPriority.high.advanced(by: 1) XCTAssertEqual(higherPriority.value, highPriority.value + 1) } - - func testLayoutConstraintEqual() { - let view1 = View() - let view2 = View() - let layoutConstraint1 = LayoutConstraint(item: view1, - attribute: .top, - relatedBy: .lessThanOrEqual, - toItem: view2, - attribute: .bottom, - multiplier: 2, - constant: 30) - let layoutConstraint2 = LayoutConstraint(item: view1, - attribute: .top, - relatedBy: .lessThanOrEqual, - toItem: view2, - attribute: .bottom, - multiplier: 2, - constant: 30) - let layoutConstraint3 = LayoutConstraint(item: view1, - attribute: .top, - relatedBy: .lessThanOrEqual, - toItem: view2, - attribute: .bottom, - multiplier: 1, - constant: 50) - XCTAssertTrue(layoutConstraint1 == layoutConstraint2) - XCTAssertFalse(layoutConstraint1 == layoutConstraint3) - XCTAssertFalse(layoutConstraint2 == layoutConstraint3) - } - } From 4cb3e3a938b5f1a1ef0874aa95f4f83907876555 Mon Sep 17 00:00:00 2001 From: Robert Payne Date: Sun, 28 Apr 2019 20:44:54 +1200 Subject: [PATCH 26/57] Update Podspec --- SnapKit.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SnapKit.podspec b/SnapKit.podspec index e0c5df3..53bc3a5 100644 --- a/SnapKit.podspec +++ b/SnapKit.podspec @@ -6,7 +6,7 @@ Pod::Spec.new do |s| s.homepage = 'https://github.com/SnapKit/SnapKit' s.authors = { 'Robert Payne' => 'robertpayne@me.com' } s.social_media_url = 'http://twitter.com/robertjpayne' - s.source = { :git => 'https://github.com/SnapKit/SnapKit.git', :tag => '5.0.0' } + s.source = { :git => 'https://github.com/SnapKit/SnapKit.git', :tag => '5.0.1' } s.ios.deployment_target = '10.0' s.osx.deployment_target = '10.12' From 5b0282cf8babe52d8e0d3207540ab317adb1e986 Mon Sep 17 00:00:00 2001 From: Robert Payne Date: Sun, 28 Apr 2019 20:57:48 +1200 Subject: [PATCH 27/57] Bump min version requirements --- SnapKit.xcodeproj/project.pbxproj | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/SnapKit.xcodeproj/project.pbxproj b/SnapKit.xcodeproj/project.pbxproj index 53ab8b9..bd593d0 100644 --- a/SnapKit.xcodeproj/project.pbxproj +++ b/SnapKit.xcodeproj/project.pbxproj @@ -324,6 +324,7 @@ developmentRegion = English; hasScannedForEncodings = 0; knownRegions = ( + English, en, Base, ); @@ -526,7 +527,9 @@ DEFINES_MODULE = YES; DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.12; PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_BUNDLE_PACKAGE_TYPE = FMWK; PRODUCT_NAME = SnapKit; @@ -547,7 +550,9 @@ DEFINES_MODULE = YES; DYLIB_INSTALL_NAME_BASE = "@rpath"; INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.12; PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_BUNDLE_PACKAGE_TYPE = FMWK; PRODUCT_NAME = SnapKit; @@ -564,7 +569,9 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = "$(SRCROOT)/Tests/SnapKitTests/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks @loader_path/../Frameworks @executable_path/../Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.12; PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 4.2; @@ -577,7 +584,9 @@ "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer"; DEVELOPMENT_TEAM = ""; INFOPLIST_FILE = "$(SRCROOT)/Tests/SnapKitTests/Info.plist"; + IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks @loader_path/../Frameworks @executable_path/../Frameworks"; + MACOSX_DEPLOYMENT_TARGET = 10.12; PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; From c904582015d5a8eed917d79a7f28ea2b5a8ddde3 Mon Sep 17 00:00:00 2001 From: Robert Payne Date: Sun, 28 Apr 2019 20:57:54 +1200 Subject: [PATCH 28/57] Fix layout constraint comparison --- Source/LayoutConstraint.swift | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/Source/LayoutConstraint.swift b/Source/LayoutConstraint.swift index 8bb5ed2..9abb45f 100644 --- a/Source/LayoutConstraint.swift +++ b/Source/LayoutConstraint.swift @@ -44,9 +44,21 @@ public class LayoutConstraint : NSLayoutConstraint { } internal func ==(lhs: LayoutConstraint, rhs: LayoutConstraint) -> Bool { - guard lhs.firstItem === rhs.firstItem && - lhs.secondItem === rhs.secondItem && - lhs.firstAttribute == rhs.firstAttribute && + // ensure first anchor items match + guard let item1 = lhs.firstAnchor.item, + let item2 = rhs.firstAnchor.item, + item1 === item2 else { + return false + } + + // ensure second anchor items match + guard ((lhs.secondAnchor?.item == nil && rhs.secondAnchor?.item == nil) || + (lhs.secondAnchor?.item === rhs.secondAnchor?.item)) else { + return false + } + + // ensure attributes, relation, priorty and multiplier match + guard lhs.firstAttribute == rhs.firstAttribute && lhs.secondAttribute == rhs.secondAttribute && lhs.relation == rhs.relation && lhs.priority == rhs.priority && From 9ee45b354dc5eb3b088e9bb2baf37a579e1100b6 Mon Sep 17 00:00:00 2001 From: Robert Payne Date: Sun, 28 Apr 2019 23:06:23 +1200 Subject: [PATCH 29/57] Fix equality check for iOS --- Source/LayoutConstraint.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Source/LayoutConstraint.swift b/Source/LayoutConstraint.swift index 9abb45f..bf8ef3f 100644 --- a/Source/LayoutConstraint.swift +++ b/Source/LayoutConstraint.swift @@ -44,6 +44,7 @@ public class LayoutConstraint : NSLayoutConstraint { } internal func ==(lhs: LayoutConstraint, rhs: LayoutConstraint) -> Bool { + #if os(OSX) // ensure first anchor items match guard let item1 = lhs.firstAnchor.item, let item2 = rhs.firstAnchor.item, @@ -56,6 +57,16 @@ internal func ==(lhs: LayoutConstraint, rhs: LayoutConstraint) -> Bool { (lhs.secondAnchor?.item === rhs.secondAnchor?.item)) else { return false } + #else + guard lhs.firstAnchor == rhs.firstAnchor else { + return false + } + guard ((lhs.secondAnchor == nil && rhs.secondAnchor == nil) || + (lhs.secondAnchor! == rhs.secondAnchor!)) else { + return false + } + #endif + // ensure attributes, relation, priorty and multiplier match guard lhs.firstAttribute == rhs.firstAttribute && From 04e9c890aa4ccf82dbd1759cd7f53cb0eabe0c02 Mon Sep 17 00:00:00 2001 From: Josh Converse Date: Mon, 10 Jun 2019 05:32:33 -0700 Subject: [PATCH 30/57] Adds support for NSDirectionalEdgeInsets as an inset constant (#594) --- SnapKit.xcodeproj/project.pbxproj | 8 ++ Source/Constraint.swift | 9 ++ Source/ConstraintConstantTarget.swift | 42 ++++++++++ Source/ConstraintDirectionalInsetTarget.swift | 49 +++++++++++ Source/ConstraintDirectionalInsets.swift | 34 ++++++++ Source/ConstraintMakerEditable.swift | 8 ++ Source/ConstraintRelatableTarget.swift | 6 ++ Tests/SnapKitTests/Tests.swift | 84 +++++++++++++++++++ 8 files changed, 240 insertions(+) create mode 100644 Source/ConstraintDirectionalInsetTarget.swift create mode 100644 Source/ConstraintDirectionalInsets.swift diff --git a/SnapKit.xcodeproj/project.pbxproj b/SnapKit.xcodeproj/project.pbxproj index bd593d0..ec9c269 100644 --- a/SnapKit.xcodeproj/project.pbxproj +++ b/SnapKit.xcodeproj/project.pbxproj @@ -8,6 +8,8 @@ /* Begin PBXBuildFile section */ 2DBA080E1F1FAD66001CFED4 /* Typealiases.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DBA080D1F1FAD66001CFED4 /* Typealiases.swift */; }; + 7E1CB2AE227BB5520066B6C0 /* ConstraintDirectionalInsetTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E1CB2AD227BB5520066B6C0 /* ConstraintDirectionalInsetTarget.swift */; }; + 7E1CB2B0227BBDF70066B6C0 /* ConstraintDirectionalInsets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E1CB2AF227BBDF70066B6C0 /* ConstraintDirectionalInsets.swift */; }; EE235F5F1C5785BC00C08960 /* Debugging.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235F5E1C5785BC00C08960 /* Debugging.swift */; }; EE235F6D1C5785C600C08960 /* Constraint.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235F621C5785C600C08960 /* Constraint.swift */; }; EE235F701C5785C600C08960 /* ConstraintDescription.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235F631C5785C600C08960 /* ConstraintDescription.swift */; }; @@ -49,6 +51,8 @@ /* Begin PBXFileReference section */ 2DBA080D1F1FAD66001CFED4 /* Typealiases.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Typealiases.swift; sourceTree = ""; }; 537DCE9A1C35CD4100B5B899 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.1.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; + 7E1CB2AD227BB5520066B6C0 /* ConstraintDirectionalInsetTarget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConstraintDirectionalInsetTarget.swift; sourceTree = ""; }; + 7E1CB2AF227BBDF70066B6C0 /* ConstraintDirectionalInsets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConstraintDirectionalInsets.swift; sourceTree = ""; }; EE235F5E1C5785BC00C08960 /* Debugging.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Debugging.swift; sourceTree = ""; }; EE235F621C5785C600C08960 /* Constraint.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Constraint.swift; sourceTree = ""; }; EE235F631C5785C600C08960 /* ConstraintDescription.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintDescription.swift; sourceTree = ""; }; @@ -172,6 +176,7 @@ EE235F911C5785CE00C08960 /* ConstraintMultiplierTarget.swift */, EE235F921C5785CE00C08960 /* ConstraintOffsetTarget.swift */, EE235F931C5785CE00C08960 /* ConstraintInsetTarget.swift */, + 7E1CB2AD227BB5520066B6C0 /* ConstraintDirectionalInsetTarget.swift */, ); name = Targets; sourceTree = ""; @@ -183,6 +188,7 @@ EE235F621C5785C600C08960 /* Constraint.swift */, EE235F631C5785C600C08960 /* ConstraintDescription.swift */, EE235F641C5785C600C08960 /* ConstraintInsets.swift */, + 7E1CB2AF227BBDF70066B6C0 /* ConstraintDirectionalInsets.swift */, EE235F651C5785C600C08960 /* ConstraintConfig.swift */, EE235F661C5785C600C08960 /* ConstraintView.swift */, EEF68FBB1D78653000980C26 /* ConstraintLayoutGuide.swift */, @@ -372,6 +378,7 @@ EE235FB51C5785D400C08960 /* ConstraintMakerEditable.swift in Sources */, EEF68FBC1D78653000980C26 /* ConstraintLayoutGuide.swift in Sources */, EE235FAC1C5785D400C08960 /* ConstraintMaker.swift in Sources */, + 7E1CB2AE227BB5520066B6C0 /* ConstraintDirectionalInsetTarget.swift in Sources */, EE6087751E4F133E0029CF84 /* ConstraintPriority.swift in Sources */, EE235F941C5785CE00C08960 /* ConstraintRelatableTarget.swift in Sources */, EEF68FA61D784A5300980C26 /* ConstraintDSL.swift in Sources */, @@ -387,6 +394,7 @@ EE6898CB1DA7B3A100D47F33 /* LayoutConstraintItem.swift in Sources */, EE235FB21C5785D400C08960 /* ConstraintMakerPriortizable.swift in Sources */, EE235F8B1C5785C600C08960 /* LayoutConstraint.swift in Sources */, + 7E1CB2B0227BBDF70066B6C0 /* ConstraintDirectionalInsets.swift in Sources */, EE235FA31C5785CE00C08960 /* ConstraintInsetTarget.swift in Sources */, EE235F9D1C5785CE00C08960 /* ConstraintMultiplierTarget.swift in Sources */, EE235FC01C5785DC00C08960 /* ConstraintViewDSL.swift in Sources */, diff --git a/Source/Constraint.swift b/Source/Constraint.swift index dc2c7c8..ea6159e 100644 --- a/Source/Constraint.swift +++ b/Source/Constraint.swift @@ -219,6 +219,15 @@ public final class Constraint { return self } + #if os(iOS) || os(tvOS) + @discardableResult + @available(iOS 11.0, tvOS 11.0, *) + public func update(inset: ConstraintDirectionalInsetTarget) -> Constraint { + self.constant = inset.constraintDirectionalInsetTargetValue + return self + } + #endif + @discardableResult public func update(priority: ConstraintPriorityTarget) -> Constraint { self.priority = priority.constraintPriorityTargetValue diff --git a/Source/ConstraintConstantTarget.swift b/Source/ConstraintConstantTarget.swift index 24052ae..7f54907 100644 --- a/Source/ConstraintConstantTarget.swift +++ b/Source/ConstraintConstantTarget.swift @@ -40,6 +40,12 @@ extension CGSize: ConstraintConstantTarget { extension ConstraintInsets: ConstraintConstantTarget { } +#if os(iOS) || os(tvOS) +@available(iOS 11.0, tvOS 11.0, *) +extension ConstraintDirectionalInsets: ConstraintConstantTarget { +} +#endif + extension ConstraintConstantTarget { internal func constraintConstantTargetValueFor(layoutAttribute: LayoutAttribute) -> CGFloat { @@ -165,6 +171,42 @@ extension ConstraintConstantTarget { #endif } + #if os(iOS) || os(tvOS) + if #available(iOS 11.0, tvOS 11.0, *), let value = self as? ConstraintDirectionalInsets { + switch layoutAttribute { + case .left, .leftMargin: + return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? value.leading : value.trailing + case .top, .topMargin, .firstBaseline: + return value.top + case .right, .rightMargin: + return (ConstraintConfig.interfaceLayoutDirection == .leftToRight) ? -value.trailing : -value.leading + case .bottom, .bottomMargin, .lastBaseline: + return -value.bottom + case .leading, .leadingMargin: + return value.leading + case .trailing, .trailingMargin: + return -value.trailing + case .centerX, .centerXWithinMargins: + return (value.leading - value.trailing) / 2 + case .centerY, .centerYWithinMargins: + return (value.top - value.bottom) / 2 + case .width: + return -(value.leading + value.trailing) + case .height: + return -(value.top + value.bottom) + case .notAnAttribute: + return 0.0 + #if swift(>=5.0) + @unknown default: + return 0.0 + #else + default: + return 0.0 + #endif + } + } + #endif + return 0.0 } diff --git a/Source/ConstraintDirectionalInsetTarget.swift b/Source/ConstraintDirectionalInsetTarget.swift new file mode 100644 index 0000000..955aec3 --- /dev/null +++ b/Source/ConstraintDirectionalInsetTarget.swift @@ -0,0 +1,49 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) +import UIKit +#else +import AppKit +#endif + +#if os(iOS) || os(tvOS) +public protocol ConstraintDirectionalInsetTarget: ConstraintConstantTarget { +} + +@available(iOS 11.0, tvOS 11.0, *) +extension ConstraintDirectionalInsets: ConstraintDirectionalInsetTarget { +} + +extension ConstraintDirectionalInsetTarget { + + @available(iOS 11.0, tvOS 11.0, *) + internal var constraintDirectionalInsetTargetValue: ConstraintDirectionalInsets { + if let amount = self as? ConstraintDirectionalInsets { + return amount + } else { + return ConstraintDirectionalInsets(top: 0, leading: 0, bottom: 0, trailing: 0) + } + } +} +#endif diff --git a/Source/ConstraintDirectionalInsets.swift b/Source/ConstraintDirectionalInsets.swift new file mode 100644 index 0000000..ada8ed5 --- /dev/null +++ b/Source/ConstraintDirectionalInsets.swift @@ -0,0 +1,34 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +#if os(iOS) || os(tvOS) + @available(iOS 11.0, tvOS 11.0, *) + public typealias ConstraintDirectionalInsets = NSDirectionalEdgeInsets +#endif diff --git a/Source/ConstraintMakerEditable.swift b/Source/ConstraintMakerEditable.swift index fb88c41..f768a17 100644 --- a/Source/ConstraintMakerEditable.swift +++ b/Source/ConstraintMakerEditable.swift @@ -53,4 +53,12 @@ public class ConstraintMakerEditable: ConstraintMakerPriortizable { return self } + #if os(iOS) || os(tvOS) + @discardableResult + @available(iOS 11.0, tvOS 11.0, *) + public func inset(_ amount: ConstraintDirectionalInsetTarget) -> ConstraintMakerEditable { + self.description.constant = amount.constraintDirectionalInsetTargetValue + return self + } + #endif } diff --git a/Source/ConstraintRelatableTarget.swift b/Source/ConstraintRelatableTarget.swift index 6976367..d517a61 100644 --- a/Source/ConstraintRelatableTarget.swift +++ b/Source/ConstraintRelatableTarget.swift @@ -55,6 +55,12 @@ extension CGPoint: ConstraintRelatableTarget { extension ConstraintInsets: ConstraintRelatableTarget { } +#if os(iOS) || os(tvOS) +@available(iOS 11.0, tvOS 11.0, *) +extension ConstraintDirectionalInsets: ConstraintRelatableTarget { +} +#endif + extension ConstraintItem: ConstraintRelatableTarget { } diff --git a/Tests/SnapKitTests/Tests.swift b/Tests/SnapKitTests/Tests.swift index a4b587f..750ea1d 100644 --- a/Tests/SnapKitTests/Tests.swift +++ b/Tests/SnapKitTests/Tests.swift @@ -413,6 +413,90 @@ class SnapKitTests: XCTestCase { XCTAssertEqual(constraints[3].constant, -25, "Should be -25") } + #if os(iOS) || os(tvOS) + @available(iOS 11.0, tvOS 11.0, *) + func testConstraintDirectionalInsetsAsImpliedEqualToConstraints() { + let view = View() + self.container.addSubview(view) + + view.snp.makeConstraints { (make) -> Void in + make.top.leading.bottom.trailing.equalTo(self.container).inset(ConstraintDirectionalInsets(top: 25, leading: 25, bottom: 25, trailing: 25)) + } + + XCTAssertEqual(self.container.snp_constraints.count, 4, "Should have 4 constraints") + + + let constraints = (self.container.snp_constraints as! [NSLayoutConstraint]).sorted { $0.firstAttribute.rawValue < $1.firstAttribute.rawValue } + + let verify: (NSLayoutConstraint, NSLayoutConstraint.Attribute, CGFloat) -> Void = { constraint, attribute, constant in + XCTAssertEqual(constraint.firstAttribute, attribute, "First attribute \(constraint.firstAttribute.rawValue) is not \(attribute.rawValue)") + XCTAssertEqual(constraint.secondAttribute, attribute, "Second attribute \(constraint.secondAttribute.rawValue) is not \(attribute.rawValue)") + XCTAssertEqual(constraint.constant, constant, "Attribute \(attribute.rawValue) should have constant \(constant)") + } + + verify(constraints[0], .top, 25) + verify(constraints[1], .bottom, -25) + verify(constraints[2], .leading, 25) + verify(constraints[3], .trailing, -25) + } + #endif + + #if os(iOS) || os(tvOS) + @available(iOS 11.0, tvOS 11.0, *) + func testConstraintDirectionalInsetsAsConstraintsConstant() { + let view = View() + self.container.addSubview(view) + + view.snp.makeConstraints { (make) -> Void in + make.top.leading.bottom.trailing.equalTo(self.container).inset(ConstraintDirectionalInsets(top: 25, leading: 25, bottom: 25, trailing: 25)) + } + + XCTAssertEqual(self.container.snp_constraints.count, 4, "Should have 4 constraints") + + + let constraints = (self.container.snp_constraints as! [NSLayoutConstraint]).sorted { $0.firstAttribute.rawValue < $1.firstAttribute.rawValue } + + let verify: (NSLayoutConstraint, NSLayoutConstraint.Attribute, CGFloat) -> Void = { constraint, attribute, constant in + XCTAssertEqual(constraint.firstAttribute, attribute, "First attribute \(constraint.firstAttribute.rawValue) is not \(attribute.rawValue)") + XCTAssertEqual(constraint.secondAttribute, attribute, "Second attribute \(constraint.secondAttribute.rawValue) is not \(attribute.rawValue)") + XCTAssertEqual(constraint.constant, constant, "Attribute \(attribute.rawValue) should have constant \(constant)") + } + + verify(constraints[0], .top, 25) + verify(constraints[1], .bottom, -25) + verify(constraints[2], .leading, 25) + verify(constraints[3], .trailing, -25) + } + #endif + + #if os(iOS) || os(tvOS) + @available(iOS 11.0, tvOS 11.0, *) + func testConstraintDirectionalInsetsFallBackForNonDirectionalConstraints() { + let view = View() + self.container.addSubview(view) + + view.snp.makeConstraints { (make) -> Void in + make.edges.equalTo(self.container).inset(ConstraintDirectionalInsets(top: 25, leading: 25, bottom: 25, trailing: 25)) + } + + XCTAssertEqual(self.container.snp_constraints.count, 4, "Should have 4 constraints") + + + let constraints = (self.container.snp_constraints as! [NSLayoutConstraint]).sorted { $0.firstAttribute.rawValue < $1.firstAttribute.rawValue } + + let verify: (NSLayoutConstraint, NSLayoutConstraint.Attribute, CGFloat) -> Void = { constraint, attribute, constant in + XCTAssertEqual(constraint.firstAttribute, attribute, "First attribute \(constraint.firstAttribute.rawValue) is not \(attribute.rawValue)") + XCTAssertEqual(constraint.secondAttribute, attribute, "Second attribute \(constraint.secondAttribute.rawValue) is not \(attribute.rawValue)") + XCTAssertEqual(constraint.constant, constant, "Attribute \(attribute.rawValue) should have constant \(constant)") + } + + verify(constraints[0], .left, 25) + verify(constraints[1], .right, -25) + verify(constraints[2], .top, 25) + verify(constraints[3], .bottom, -25) + } + #endif + func testSizeConstraints() { let view = View() self.container.addSubview(view) From 222e14ab374cfda30285cae6c1bb93a635f44526 Mon Sep 17 00:00:00 2001 From: Vitalii Budnik Date: Mon, 10 Jun 2019 15:33:33 +0300 Subject: [PATCH 31/57] Make ConstraintViewDSL content priorities nonmutating (#586) --- Source/ConstraintViewDSL.swift | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Source/ConstraintViewDSL.swift b/Source/ConstraintViewDSL.swift index 298bdb1..a0187f9 100644 --- a/Source/ConstraintViewDSL.swift +++ b/Source/ConstraintViewDSL.swift @@ -55,7 +55,7 @@ public struct ConstraintViewDSL: ConstraintAttributesDSL { get { return self.view.contentHuggingPriority(for: .horizontal).rawValue } - set { + nonmutating set { self.view.setContentHuggingPriority(LayoutPriority(rawValue: newValue), for: .horizontal) } } @@ -64,7 +64,7 @@ public struct ConstraintViewDSL: ConstraintAttributesDSL { get { return self.view.contentHuggingPriority(for: .vertical).rawValue } - set { + nonmutating set { self.view.setContentHuggingPriority(LayoutPriority(rawValue: newValue), for: .vertical) } } @@ -73,7 +73,7 @@ public struct ConstraintViewDSL: ConstraintAttributesDSL { get { return self.view.contentCompressionResistancePriority(for: .horizontal).rawValue } - set { + nonmutating set { self.view.setContentCompressionResistancePriority(LayoutPriority(rawValue: newValue), for: .horizontal) } } @@ -82,7 +82,7 @@ public struct ConstraintViewDSL: ConstraintAttributesDSL { get { return self.view.contentCompressionResistancePriority(for: .vertical).rawValue } - set { + nonmutating set { self.view.setContentCompressionResistancePriority(LayoutPriority(rawValue: newValue), for: .vertical) } } From d482f59648e580a5d550a2e85bee04973c6df9ec Mon Sep 17 00:00:00 2001 From: Josh Converse Date: Sun, 4 Aug 2019 22:16:17 -0700 Subject: [PATCH 32/57] =?UTF-8?q?Adds=20two=20new=20compositions=20?= =?UTF-8?q?=E2=80=93=C2=A0DirectionalEdges=20and=20DirectionalMargins=20(#?= =?UTF-8?q?595)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * WIP * Add directional margins * Whitespace --- Source/Constraint.swift | 26 +++++++++++ Source/ConstraintAttributes.swift | 4 ++ Source/ConstraintDSL.swift | 9 ++++ Source/ConstraintMaker.swift | 8 ++++ Source/ConstraintMakerExtendable.swift | 10 +++++ Source/ConstraintMakerRelatable.swift | 4 +- Tests/SnapKitTests/Tests.swift | 62 ++++++++++++++++++++++++++ 7 files changed, 122 insertions(+), 1 deletion(-) diff --git a/Source/Constraint.swift b/Source/Constraint.swift index ea6159e..390629e 100644 --- a/Source/Constraint.swift +++ b/Source/Constraint.swift @@ -129,6 +129,32 @@ public final class Constraint { default: fatalError() } + } else if self.from.attributes == .directionalEdges && self.to.attributes == .directionalMargins { + switch layoutFromAttribute { + case .leading: + layoutToAttribute = .leadingMargin + case .trailing: + layoutToAttribute = .trailingMargin + case .top: + layoutToAttribute = .topMargin + case .bottom: + layoutToAttribute = .bottomMargin + default: + fatalError() + } + } else if self.from.attributes == .directionalMargins && self.to.attributes == .directionalEdges { + switch layoutFromAttribute { + case .leadingMargin: + layoutToAttribute = .leading + case .trailingMargin: + layoutToAttribute = .trailing + case .topMargin: + layoutToAttribute = .top + case .bottomMargin: + layoutToAttribute = .bottom + default: + fatalError() + } } else if self.from.attributes == self.to.attributes { layoutToAttribute = layoutFromAttribute } else { diff --git a/Source/ConstraintAttributes.swift b/Source/ConstraintAttributes.swift index 5e2367e..2f0fbe9 100644 --- a/Source/ConstraintAttributes.swift +++ b/Source/ConstraintAttributes.swift @@ -99,12 +99,16 @@ internal struct ConstraintAttributes : OptionSet, ExpressibleByIntegerLiteral { // aggregates internal static var edges: ConstraintAttributes { return 15 } + internal static var directionalEdges: ConstraintAttributes { return 58 } internal static var size: ConstraintAttributes { return 192 } internal static var center: ConstraintAttributes { return 768 } @available(iOS 8.0, *) internal static var margins: ConstraintAttributes { return 61440 } + @available(iOS 8.0, *) + internal static var directionalMargins: ConstraintAttributes { return 245760 } + @available(iOS 8.0, *) internal static var centerWithinMargins: ConstraintAttributes { return 786432 } diff --git a/Source/ConstraintDSL.swift b/Source/ConstraintDSL.swift index b7aad57..ecc5173 100644 --- a/Source/ConstraintDSL.swift +++ b/Source/ConstraintDSL.swift @@ -99,6 +99,10 @@ extension ConstraintBasicAttributesDSL { return ConstraintItem(target: self.target, attributes: ConstraintAttributes.edges) } + public var directionalEdges: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.directionalEdges) + } + public var size: ConstraintItem { return ConstraintItem(target: self.target, attributes: ConstraintAttributes.size) } @@ -177,6 +181,11 @@ extension ConstraintAttributesDSL { return ConstraintItem(target: self.target, attributes: ConstraintAttributes.margins) } + @available(iOS 8.0, *) + public var directionalMargins: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.directionalMargins) + } + @available(iOS 8.0, *) public var centerWithinMargins: ConstraintItem { return ConstraintItem(target: self.target, attributes: ConstraintAttributes.centerWithinMargins) diff --git a/Source/ConstraintMaker.swift b/Source/ConstraintMaker.swift index ed2879b..38f4d31 100644 --- a/Source/ConstraintMaker.swift +++ b/Source/ConstraintMaker.swift @@ -126,6 +126,9 @@ public class ConstraintMaker { public var edges: ConstraintMakerExtendable { return self.makeExtendableWithAttributes(.edges) } + public var directionalEdges: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.directionalEdges) + } public var size: ConstraintMakerExtendable { return self.makeExtendableWithAttributes(.size) } @@ -138,6 +141,11 @@ public class ConstraintMaker { return self.makeExtendableWithAttributes(.margins) } + @available(iOS 8.0, *) + public var directionalMargins: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.directionalMargins) + } + @available(iOS 8.0, *) public var centerWithinMargins: ConstraintMakerExtendable { return self.makeExtendableWithAttributes(.centerWithinMargins) diff --git a/Source/ConstraintMakerExtendable.swift b/Source/ConstraintMakerExtendable.swift index 243e54e..ce47169 100644 --- a/Source/ConstraintMakerExtendable.swift +++ b/Source/ConstraintMakerExtendable.swift @@ -149,6 +149,10 @@ public class ConstraintMakerExtendable: ConstraintMakerRelatable { self.description.attributes += .edges return self } + public var directionalEdges: ConstraintMakerExtendable { + self.description.attributes += .directionalEdges + return self + } public var size: ConstraintMakerExtendable { self.description.attributes += .size return self @@ -160,6 +164,12 @@ public class ConstraintMakerExtendable: ConstraintMakerRelatable { return self } + @available(iOS 8.0, *) + public var directionalMargins: ConstraintMakerExtendable { + self.description.attributes += .directionalMargins + return self + } + @available(iOS 8.0, *) public var centerWithinMargins: ConstraintMakerExtendable { self.description.attributes += .centerWithinMargins diff --git a/Source/ConstraintMakerRelatable.swift b/Source/ConstraintMakerRelatable.swift index 98c7158..7889532 100644 --- a/Source/ConstraintMakerRelatable.swift +++ b/Source/ConstraintMakerRelatable.swift @@ -45,7 +45,9 @@ public class ConstraintMakerRelatable { other.attributes.layoutAttributes.count <= 1 || other.attributes.layoutAttributes == self.description.attributes.layoutAttributes || other.attributes == .edges && self.description.attributes == .margins || - other.attributes == .margins && self.description.attributes == .edges else { + other.attributes == .margins && self.description.attributes == .edges || + other.attributes == .directionalEdges && self.description.attributes == .directionalMargins || + other.attributes == .directionalMargins && self.description.attributes == .directionalEdges else { fatalError("Cannot constraint to multiple non identical attributes. (\(file), \(line))"); } diff --git a/Tests/SnapKitTests/Tests.swift b/Tests/SnapKitTests/Tests.swift index 750ea1d..8addd50 100644 --- a/Tests/SnapKitTests/Tests.swift +++ b/Tests/SnapKitTests/Tests.swift @@ -575,6 +575,28 @@ class SnapKitTests: XCTestCase { XCTAssert(fromAttributes == [.top, .left, .bottom, .right]) XCTAssert(toAttributes == [.top, .left, .bottom, .right]) } + + func testDirectionalEdgesToDirectionalEdges() { + var fromAttributes = Set() + var toAttributes = Set() + + let view = View() + self.container.addSubview(view) + + view.snp.remakeConstraints { (make) -> Void in + make.directionalEdges.equalTo(self.container.snp.directionalEdges) + } + + XCTAssertEqual(self.container.snp_constraints.count, 4, "Should have 4 constraints") + + for constraint in (container.snp_constraints as! [NSLayoutConstraint]) { + fromAttributes.insert(constraint.firstAttribute) + toAttributes.insert(constraint.secondAttribute) + } + + XCTAssert(fromAttributes == [.top, .leading, .bottom, .trailing]) + XCTAssert(toAttributes == [.top, .leading, .bottom, .trailing]) + } #if os(iOS) || os(tvOS) func testEdgesToMargins() { @@ -616,6 +638,46 @@ class SnapKitTests: XCTestCase { XCTAssert(fromAttributes == [.topMargin, .leftMargin, .bottomMargin, .rightMargin]) } + + func testDirectionalEdgesToDirectionalMargins() { + var fromAttributes = Set() + var toAttributes = Set() + + let view = View() + self.container.addSubview(view) + + view.snp.remakeConstraints { (make) -> Void in + make.directionalEdges.equalTo(self.container.snp.directionalMargins) + } + + XCTAssertEqual(self.container.snp_constraints.count, 4, "Should have 4 constraints") + + for constraint in (container.snp_constraints as! [NSLayoutConstraint]) { + fromAttributes.insert(constraint.firstAttribute) + toAttributes.insert(constraint.secondAttribute) + } + + XCTAssert(fromAttributes == [.top, .leading, .bottom, .trailing]) + XCTAssert(toAttributes == [.topMargin, .leadingMargin, .bottomMargin, .trailingMargin]) + + fromAttributes.removeAll() + toAttributes.removeAll() + + view.snp.remakeConstraints { (make) -> Void in + make.directionalMargins.equalTo(self.container.snp.directionalEdges) + } + + XCTAssertEqual(self.container.snp_constraints.count, 4, "Should have 4 constraints") + + for constraint in (container.snp_constraints as! [NSLayoutConstraint]) { + fromAttributes.insert(constraint.firstAttribute) + toAttributes.insert(constraint.secondAttribute) + } + + XCTAssert(toAttributes == [.top, .leading, .bottom, .trailing]) + XCTAssert(fromAttributes == [.topMargin, .leadingMargin, .bottomMargin, .trailingMargin]) + + } func testLayoutGuideConstraints() { let vc = UIViewController() From df9df818dd2254f9f884f7bd814141c694f5a905 Mon Sep 17 00:00:00 2001 From: Shiva Huang Date: Mon, 5 Aug 2019 13:16:46 +0800 Subject: [PATCH 33/57] Add Playground Sample (#608) --- README.md | 7 +++++ SnapKit.xcworkspace/contents.xcworkspacedata | 3 ++ .../xcshareddata/IDEWorkspaceChecks.plist | 8 +++++ SnapKitPlayground.playground/Contents.swift | 29 +++++++++++++++++++ .../contents.xcplayground | 4 +++ .../timeline.xctimeline | 6 ++++ 6 files changed, 57 insertions(+) create mode 100644 SnapKit.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist create mode 100644 SnapKitPlayground.playground/Contents.swift create mode 100644 SnapKitPlayground.playground/contents.xcplayground create mode 100644 SnapKitPlayground.playground/timeline.xctimeline diff --git a/README.md b/README.md index 32b6518..0945ce6 100644 --- a/README.md +++ b/README.md @@ -114,6 +114,13 @@ class MyViewController: UIViewController { } ``` +### Playground +You can try SnapKit in Playground. + +**Note:** + +> To try SnapKit in playground, open `SnapKit.xcworkspace` and build SnapKit.framework for any simulator first. + ### Resources - [Documentation](http://snapkit.io/docs/) diff --git a/SnapKit.xcworkspace/contents.xcworkspacedata b/SnapKit.xcworkspace/contents.xcworkspacedata index 6814365..c59d3d6 100644 --- a/SnapKit.xcworkspace/contents.xcworkspacedata +++ b/SnapKit.xcworkspace/contents.xcworkspacedata @@ -1,6 +1,9 @@ + + diff --git a/SnapKit.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/SnapKit.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/SnapKit.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + + diff --git a/SnapKitPlayground.playground/Contents.swift b/SnapKitPlayground.playground/Contents.swift new file mode 100644 index 0000000..d84900a --- /dev/null +++ b/SnapKitPlayground.playground/Contents.swift @@ -0,0 +1,29 @@ +//: A UIKit based Playground for presenting user interface +// To use this playground, build SnapKit.framework for any simulator first. + +import SnapKit +import UIKit +import PlaygroundSupport + +class MyViewController : UIViewController { + override func loadView() { + let view = UIView() + view.backgroundColor = .white + + let label = UILabel() + label.text = "Hello World!" + label.textColor = .black + + view.addSubview(label) + + label.snp.makeConstraints { (make) in + make.left.equalToSuperview().offset(150) + make.top.equalToSuperview().offset(200) + make.size.equalTo(CGSize(width: 200, height: 20)) + } + + self.view = view + } +} +// Present the view controller in the Live View window +PlaygroundPage.current.liveView = MyViewController() diff --git a/SnapKitPlayground.playground/contents.xcplayground b/SnapKitPlayground.playground/contents.xcplayground new file mode 100644 index 0000000..3b15108 --- /dev/null +++ b/SnapKitPlayground.playground/contents.xcplayground @@ -0,0 +1,4 @@ + + + + \ No newline at end of file diff --git a/SnapKitPlayground.playground/timeline.xctimeline b/SnapKitPlayground.playground/timeline.xctimeline new file mode 100644 index 0000000..bf468af --- /dev/null +++ b/SnapKitPlayground.playground/timeline.xctimeline @@ -0,0 +1,6 @@ + + + + + From bffbeecd1096dd5875a121d9ce24b411b53ab27d Mon Sep 17 00:00:00 2001 From: Max Cobb <5754073+maxxfrazer@users.noreply.github.com> Date: Mon, 5 Aug 2019 06:17:03 +0100 Subject: [PATCH 34/57] added updates to Package.swift so it can be imported with Xcode 11 (#615) --- .gitignore | 1 + Package.swift | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/.gitignore b/.gitignore index 79fa0df..c15ee17 100644 --- a/.gitignore +++ b/.gitignore @@ -6,3 +6,4 @@ Examples/ Gemfile Gemfile.lock *.sketch +.swiftpm diff --git a/Package.swift b/Package.swift index 865eabf..fb37579 100644 --- a/Package.swift +++ b/Package.swift @@ -27,11 +27,19 @@ import PackageDescription let package = Package( name: "SnapKit", + platforms: [ + .iOS(.v10), + .macOS(.v10_12), + .tvOS(.v10) + ], products: [ .library(name: "SnapKit", targets: ["SnapKit"]), ], targets: [ .target(name: "SnapKit", path: "Source"), .testTarget(name: "SnapKitTests", dependencies: ["SnapKit"]), + ], + swiftLanguageVersions: [ + .v5 ] ) From 1754aed4dcfeda4e16b700e7b8095c73169c7cec Mon Sep 17 00:00:00 2001 From: Robert Payne Date: Mon, 5 Aug 2019 18:16:37 +1200 Subject: [PATCH 35/57] Revert #574 --- Source/LayoutConstraint.swift | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) diff --git a/Source/LayoutConstraint.swift b/Source/LayoutConstraint.swift index bf8ef3f..5425ea8 100644 --- a/Source/LayoutConstraint.swift +++ b/Source/LayoutConstraint.swift @@ -44,36 +44,17 @@ public class LayoutConstraint : NSLayoutConstraint { } internal func ==(lhs: LayoutConstraint, rhs: LayoutConstraint) -> Bool { - #if os(OSX) - // ensure first anchor items match - guard let item1 = lhs.firstAnchor.item, - let item2 = rhs.firstAnchor.item, - item1 === item2 else { - return false - } - - // ensure second anchor items match - guard ((lhs.secondAnchor?.item == nil && rhs.secondAnchor?.item == nil) || - (lhs.secondAnchor?.item === rhs.secondAnchor?.item)) else { - return false - } - #else - guard lhs.firstAnchor == rhs.firstAnchor else { - return false - } - guard ((lhs.secondAnchor == nil && rhs.secondAnchor == nil) || - (lhs.secondAnchor! == rhs.secondAnchor!)) else { - return false - } - #endif - - - // ensure attributes, relation, priorty and multiplier match + // If firstItem or secondItem on either constraint has a dangling pointer + // this comparison can cause a crash. The solution for this is to ensure + // your layout code hold strong references to things like Views, LayoutGuides + // and LayoutAnchors as SnapKit will not keep strong references to any of these. guard lhs.firstAttribute == rhs.firstAttribute && lhs.secondAttribute == rhs.secondAttribute && lhs.relation == rhs.relation && lhs.priority == rhs.priority && - lhs.multiplier == rhs.multiplier else { + lhs.multiplier == rhs.multiplier && + lhs.secondItem === rhs.secondItem && + lhs.firstItem === rhs.firstItem else { return false } return true From d458564516e5676af9c70b4f4b2a9178294f1bc6 Mon Sep 17 00:00:00 2001 From: Robert Payne Date: Mon, 5 Aug 2019 18:29:37 +1200 Subject: [PATCH 36/57] Update Podspec --- SnapKit.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SnapKit.podspec b/SnapKit.podspec index 53bc3a5..7f99095 100644 --- a/SnapKit.podspec +++ b/SnapKit.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'SnapKit' - s.version = '5.0.0' + s.version = '5.0.1' s.license = 'MIT' s.summary = 'Harness the power of auto layout with a simplified, chainable, and compile time safe syntax.' s.homepage = 'https://github.com/SnapKit/SnapKit' From 198b62402fe428babf6847c38bfa22c2529e038d Mon Sep 17 00:00:00 2001 From: Liam Elmore <32336260+iosmo@users.noreply.github.com> Date: Mon, 5 Aug 2019 09:39:18 +0100 Subject: [PATCH 37/57] Add background color to quick start box in README.md (#619) --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 0945ce6..ecc209c 100644 --- a/README.md +++ b/README.md @@ -7,8 +7,8 @@ SnapKit is a DSL to make Auto Layout easy on both iOS and OS X. [![Cocoapods Compatible](https://img.shields.io/cocoapods/v/SnapKit.svg)](https://cocoapods.org/pods/SnapKit) [![Carthage compatible](https://img.shields.io/badge/Carthage-compatible-4BC51D.svg?style=flat)](https://github.com/Carthage/Carthage) -#### ⚠️ **To use with Swift 4.x please ensure you are using >= 4.0.0** ⚠️ -#### ⚠️ **To use with Swift 5.x please ensure you are using >= 5.0.0** ⚠️ +#### ⚠️ **To use with Swift 4.x please ensure you are using >= 4.0.0** ⚠️ +#### ⚠️ **To use with Swift 5.x please ensure you are using >= 5.0.0** ⚠️ ## Contents @@ -105,6 +105,7 @@ class MyViewController: UIViewController { super.viewDidLoad() self.view.addSubview(box) + box.backgroundColor = .green box.snp.makeConstraints { (make) -> Void in make.width.height.equalTo(50) make.center.equalTo(self.view) From 892722a93361e6c7ac67feab1b0e79b9070deef9 Mon Sep 17 00:00:00 2001 From: Sven Driemecker Date: Wed, 27 Nov 2019 11:26:09 +0100 Subject: [PATCH 38/57] add-dimensional-edges: add ConstraintItems horizontalEdges, verticalEdges, directionalHorizontalEdges and directionalVerticalEdges as convenience items to express left+right, top+bottom or leading+trailing (#637) --- Source/ConstraintAttributes.swift | 4 +++ Source/ConstraintDSL.swift | 16 +++++++++++ Source/ConstraintMaker.swift | 12 ++++++++ Source/ConstraintMakerExtendable.swift | 16 +++++++++++ Tests/SnapKitTests/Tests.swift | 40 ++++++++++++++++++++++++++ 5 files changed, 88 insertions(+) diff --git a/Source/ConstraintAttributes.swift b/Source/ConstraintAttributes.swift index 2f0fbe9..5879c1a 100644 --- a/Source/ConstraintAttributes.swift +++ b/Source/ConstraintAttributes.swift @@ -99,7 +99,11 @@ internal struct ConstraintAttributes : OptionSet, ExpressibleByIntegerLiteral { // aggregates internal static var edges: ConstraintAttributes { return 15 } + internal static var horizontalEdges: ConstraintAttributes { return 5 } + internal static var verticalEdges: ConstraintAttributes { return 10 } internal static var directionalEdges: ConstraintAttributes { return 58 } + internal static var directionalHorizontalEdges: ConstraintAttributes { return 48 } + internal static var directionalVerticalEdges: ConstraintAttributes { return 10 } internal static var size: ConstraintAttributes { return 192 } internal static var center: ConstraintAttributes { return 768 } diff --git a/Source/ConstraintDSL.swift b/Source/ConstraintDSL.swift index ecc5173..af7657f 100644 --- a/Source/ConstraintDSL.swift +++ b/Source/ConstraintDSL.swift @@ -103,6 +103,22 @@ extension ConstraintBasicAttributesDSL { return ConstraintItem(target: self.target, attributes: ConstraintAttributes.directionalEdges) } + public var horizontalEdges: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.horizontalEdges) + } + + public var verticalEdges: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.verticalEdges) + } + + public var directionalHorizontalEdges: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.directionalHorizontalEdges) + } + + public var directionalVerticalEdges: ConstraintItem { + return ConstraintItem(target: self.target, attributes: ConstraintAttributes.directionalVerticalEdges) + } + public var size: ConstraintItem { return ConstraintItem(target: self.target, attributes: ConstraintAttributes.size) } diff --git a/Source/ConstraintMaker.swift b/Source/ConstraintMaker.swift index 38f4d31..64c91c9 100644 --- a/Source/ConstraintMaker.swift +++ b/Source/ConstraintMaker.swift @@ -126,9 +126,21 @@ public class ConstraintMaker { public var edges: ConstraintMakerExtendable { return self.makeExtendableWithAttributes(.edges) } + public var horizontalEdges: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.horizontalEdges) + } + public var verticalEdges: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.verticalEdges) + } public var directionalEdges: ConstraintMakerExtendable { return self.makeExtendableWithAttributes(.directionalEdges) } + public var directionalHorizontalEdges: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.directionalHorizontalEdges) + } + public var directionalVerticalEdges: ConstraintMakerExtendable { + return self.makeExtendableWithAttributes(.directionalVerticalEdges) + } public var size: ConstraintMakerExtendable { return self.makeExtendableWithAttributes(.size) } diff --git a/Source/ConstraintMakerExtendable.swift b/Source/ConstraintMakerExtendable.swift index ce47169..ab90511 100644 --- a/Source/ConstraintMakerExtendable.swift +++ b/Source/ConstraintMakerExtendable.swift @@ -149,10 +149,26 @@ public class ConstraintMakerExtendable: ConstraintMakerRelatable { self.description.attributes += .edges return self } + public var horizontalEdges: ConstraintMakerExtendable { + self.description.attributes += .horizontalEdges + return self + } + public var verticalEdges: ConstraintMakerExtendable { + self.description.attributes += .verticalEdges + return self + } public var directionalEdges: ConstraintMakerExtendable { self.description.attributes += .directionalEdges return self } + public var directionalHorizontalEdges: ConstraintMakerExtendable { + self.description.attributes += .directionalHorizontalEdges + return self + } + public var directionalVerticalEdges: ConstraintMakerExtendable { + self.description.attributes += .directionalVerticalEdges + return self + } public var size: ConstraintMakerExtendable { self.description.attributes += .size return self diff --git a/Tests/SnapKitTests/Tests.swift b/Tests/SnapKitTests/Tests.swift index 8addd50..acf48aa 100644 --- a/Tests/SnapKitTests/Tests.swift +++ b/Tests/SnapKitTests/Tests.swift @@ -59,6 +59,46 @@ class SnapKitTests: XCTestCase { XCTAssertEqual(self.container.snp_constraints.count, 6, "Should have 6 constraints installed") } + + func testHorizontalVerticalEdges() { + let v1 = View() + self.container.addSubview(v1) + + v1.snp.makeConstraints { (make) -> Void in + make.verticalEdges.equalToSuperview() + make.horizontalEdges.equalToSuperview() + return + } + + XCTAssertEqual(self.container.snp_constraints.count, 4, "Should have 4 constraints installed") + + XCTAssertTrue(container.constraints.count == 4) + XCTAssertTrue(container.constraints.allSatisfy { $0.firstItem === v1 && $0.secondItem === v1.superview }) + XCTAssertNotNil(container.constraints.first { $0.firstAttribute == .left && $0.secondAttribute == .left }) + XCTAssertNotNil(container.constraints.first { $0.firstAttribute == .right && $0.secondAttribute == .right }) + XCTAssertNotNil(container.constraints.first { $0.firstAttribute == .top && $0.secondAttribute == .top }) + XCTAssertNotNil(container.constraints.first { $0.firstAttribute == .bottom && $0.secondAttribute == .bottom }) + } + + func testHorizontalVerticalDirectionalEdges() { + let v1 = View() + self.container.addSubview(v1) + + v1.snp.makeConstraints { (make) -> Void in + make.directionalVerticalEdges.equalToSuperview() + make.directionalHorizontalEdges.equalToSuperview() + return + } + + XCTAssertEqual(self.container.snp_constraints.count, 4, "Should have 4 constraints installed") + + XCTAssertTrue(container.constraints.count == 4) + XCTAssertTrue(container.constraints.allSatisfy { $0.firstItem === v1 && $0.secondItem === v1.superview }) + XCTAssertNotNil(container.constraints.first { $0.firstAttribute == .leading && $0.secondAttribute == .leading }) + XCTAssertNotNil(container.constraints.first { $0.firstAttribute == .trailing && $0.secondAttribute == .trailing }) + XCTAssertNotNil(container.constraints.first { $0.firstAttribute == .top && $0.secondAttribute == .top }) + XCTAssertNotNil(container.constraints.first { $0.firstAttribute == .bottom && $0.secondAttribute == .bottom }) + } func testGuideMakeConstraints() { guard #available(iOS 9.0, OSX 10.11, *) else { return } From 441a1695ed2e1bc212c2e2da21c617cb666a0524 Mon Sep 17 00:00:00 2001 From: Alex Simpson Date: Wed, 27 Nov 2019 12:26:43 +0200 Subject: [PATCH 39/57] Update deprecations to allow Xcode to auto-fixup. (#634) --- Source/Constraint.swift | 10 ++--- Source/ConstraintDSL.swift | 3 +- Source/ConstraintMaker.swift | 2 +- Source/ConstraintMakerExtendable.swift | 2 +- Source/ConstraintView+Extensions.swift | 62 +++++++++++++------------- 5 files changed, 39 insertions(+), 40 deletions(-) diff --git a/Source/Constraint.swift b/Source/Constraint.swift index 390629e..37409b3 100644 --- a/Source/Constraint.swift +++ b/Source/Constraint.swift @@ -215,12 +215,12 @@ public final class Constraint { // MARK: Public - @available(*, deprecated, message:"Use activate().") + @available(*, deprecated, renamed:"activate()") public func install() { self.activate() } - @available(*, deprecated, message:"Use deactivate().") + @available(*, deprecated, renamed:"deactivate()") public func uninstall() { self.deactivate() } @@ -266,13 +266,13 @@ public final class Constraint { return self } - @available(*, deprecated, message:"Use update(offset: ConstraintOffsetTarget) instead.") + @available(*, deprecated, renamed:"update(offset:)") public func updateOffset(amount: ConstraintOffsetTarget) -> Void { self.update(offset: amount) } - @available(*, deprecated, message:"Use update(inset: ConstraintInsetTarget) instead.") + @available(*, deprecated, renamed:"update(inset:)") public func updateInsets(amount: ConstraintInsetTarget) -> Void { self.update(inset: amount) } - @available(*, deprecated, message:"Use update(priority: ConstraintPriorityTarget) instead.") + @available(*, deprecated, renamed:"update(priority:)") public func updatePriority(amount: ConstraintPriorityTarget) -> Void { self.update(priority: amount) } @available(*, deprecated, message:"Use update(priority: ConstraintPriorityTarget) instead.") diff --git a/Source/ConstraintDSL.swift b/Source/ConstraintDSL.swift index af7657f..20f153d 100644 --- a/Source/ConstraintDSL.swift +++ b/Source/ConstraintDSL.swift @@ -134,8 +134,7 @@ public protocol ConstraintAttributesDSL : ConstraintBasicAttributesDSL { extension ConstraintAttributesDSL { // MARK: Baselines - - @available(*, deprecated, message:"Use .lastBaseline instead") + @available(*, deprecated, renamed:"lastBaseline") public var baseline: ConstraintItem { return ConstraintItem(target: self.target, attributes: ConstraintAttributes.lastBaseline) } diff --git a/Source/ConstraintMaker.swift b/Source/ConstraintMaker.swift index 64c91c9..7e48b69 100644 --- a/Source/ConstraintMaker.swift +++ b/Source/ConstraintMaker.swift @@ -69,7 +69,7 @@ public class ConstraintMaker { return self.makeExtendableWithAttributes(.centerY) } - @available(*, deprecated, message:"Use lastBaseline instead") + @available(*, deprecated, renamed:"lastBaseline") public var baseline: ConstraintMakerExtendable { return self.makeExtendableWithAttributes(.lastBaseline) } diff --git a/Source/ConstraintMakerExtendable.swift b/Source/ConstraintMakerExtendable.swift index ab90511..d834649 100644 --- a/Source/ConstraintMakerExtendable.swift +++ b/Source/ConstraintMakerExtendable.swift @@ -80,7 +80,7 @@ public class ConstraintMakerExtendable: ConstraintMakerRelatable { return self } - @available(*, deprecated, message:"Use lastBaseline instead") + @available(*, deprecated, renamed:"lastBaseline") public var baseline: ConstraintMakerExtendable { self.description.attributes += .lastBaseline return self diff --git a/Source/ConstraintView+Extensions.swift b/Source/ConstraintView+Extensions.swift index a4898dc..e0f71c1 100644 --- a/Source/ConstraintView+Extensions.swift +++ b/Source/ConstraintView+Extensions.swift @@ -30,117 +30,117 @@ public extension ConstraintView { - @available(*, deprecated, message:"Use newer snp.* syntax.") + @available(*, deprecated, renamed:"snp.left") var snp_left: ConstraintItem { return self.snp.left } - @available(*, deprecated, message:"Use newer snp.* syntax.") + @available(*, deprecated, renamed:"snp.top") var snp_top: ConstraintItem { return self.snp.top } - @available(*, deprecated, message:"Use newer snp.* syntax.") + @available(*, deprecated, renamed:"snp.right") var snp_right: ConstraintItem { return self.snp.right } - @available(*, deprecated, message:"Use newer snp.* syntax.") + @available(*, deprecated, renamed:"snp.bottom") var snp_bottom: ConstraintItem { return self.snp.bottom } - @available(*, deprecated, message:"Use newer snp.* syntax.") + @available(*, deprecated, renamed:"snp.leading") var snp_leading: ConstraintItem { return self.snp.leading } - @available(*, deprecated, message:"Use newer snp.* syntax.") + @available(*, deprecated, renamed:"snp.trailing") var snp_trailing: ConstraintItem { return self.snp.trailing } - @available(*, deprecated, message:"Use newer snp.* syntax.") + @available(*, deprecated, renamed:"snp.width") var snp_width: ConstraintItem { return self.snp.width } - @available(*, deprecated, message:"Use newer snp.* syntax.") + @available(*, deprecated, renamed:"snp.height") var snp_height: ConstraintItem { return self.snp.height } - @available(*, deprecated, message:"Use newer snp.* syntax.") + @available(*, deprecated, renamed:"snp.centerX") var snp_centerX: ConstraintItem { return self.snp.centerX } - @available(*, deprecated, message:"Use newer snp.* syntax.") + @available(*, deprecated, renamed:"snp.centerY") var snp_centerY: ConstraintItem { return self.snp.centerY } - @available(*, deprecated, message:"Use newer snp.* syntax.") + @available(*, deprecated, renamed:"snp.baseline") var snp_baseline: ConstraintItem { return self.snp.baseline } - @available(*, deprecated, message:"Use newer snp.* syntax.") + @available(*, deprecated, renamed:"snp.lastBaseline") @available(iOS 8.0, OSX 10.11, *) var snp_lastBaseline: ConstraintItem { return self.snp.lastBaseline } - @available(iOS, deprecated, message:"Use newer snp.* syntax.") + @available(iOS, deprecated, renamed:"snp.firstBaseline") @available(iOS 8.0, OSX 10.11, *) var snp_firstBaseline: ConstraintItem { return self.snp.firstBaseline } - @available(iOS, deprecated, message:"Use newer snp.* syntax.") + @available(iOS, deprecated, renamed:"snp.leftMargin") @available(iOS 8.0, *) var snp_leftMargin: ConstraintItem { return self.snp.leftMargin } - @available(iOS, deprecated, message:"Use newer snp.* syntax.") + @available(iOS, deprecated, renamed:"snp.topMargin") @available(iOS 8.0, *) var snp_topMargin: ConstraintItem { return self.snp.topMargin } - @available(iOS, deprecated, message:"Use newer snp.* syntax.") + @available(iOS, deprecated, renamed:"snp.rightMargin") @available(iOS 8.0, *) var snp_rightMargin: ConstraintItem { return self.snp.rightMargin } - @available(iOS, deprecated, message:"Use newer snp.* syntax.") + @available(iOS, deprecated, renamed:"snp.bottomMargin") @available(iOS 8.0, *) var snp_bottomMargin: ConstraintItem { return self.snp.bottomMargin } - @available(iOS, deprecated, message:"Use newer snp.* syntax.") + @available(iOS, deprecated, renamed:"snp.leadingMargin") @available(iOS 8.0, *) var snp_leadingMargin: ConstraintItem { return self.snp.leadingMargin } - @available(iOS, deprecated, message:"Use newer snp.* syntax.") + @available(iOS, deprecated, renamed:"snp.trailingMargin") @available(iOS 8.0, *) var snp_trailingMargin: ConstraintItem { return self.snp.trailingMargin } - @available(iOS, deprecated, message:"Use newer snp.* syntax.") + @available(iOS, deprecated, renamed:"snp.centerXWithinMargins") @available(iOS 8.0, *) var snp_centerXWithinMargins: ConstraintItem { return self.snp.centerXWithinMargins } - @available(iOS, deprecated, message:"Use newer snp.* syntax.") + @available(iOS, deprecated, renamed:"snp.centerYWithinMargins") @available(iOS 8.0, *) var snp_centerYWithinMargins: ConstraintItem { return self.snp.centerYWithinMargins } - @available(*, deprecated, message:"Use newer snp.* syntax.") + @available(*, deprecated, renamed:"snp.edges") var snp_edges: ConstraintItem { return self.snp.edges } - @available(*, deprecated, message:"Use newer snp.* syntax.") + @available(*, deprecated, renamed:"snp.size") var snp_size: ConstraintItem { return self.snp.size } - @available(*, deprecated, message:"Use newer snp.* syntax.") + @available(*, deprecated, renamed:"snp.center") var snp_center: ConstraintItem { return self.snp.center } - @available(iOS, deprecated, message:"Use newer snp.* syntax.") + @available(iOS, deprecated, renamed:"snp.margins") @available(iOS 8.0, *) var snp_margins: ConstraintItem { return self.snp.margins } - @available(iOS, deprecated, message:"Use newer snp.* syntax.") + @available(iOS, deprecated, renamed:"snp.centerWithinMargins") @available(iOS 8.0, *) var snp_centerWithinMargins: ConstraintItem { return self.snp.centerWithinMargins } - @available(*, deprecated, message:"Use newer snp.* syntax.") + @available(*, deprecated, renamed:"snp.prepareConstraints(_:)") func snp_prepareConstraints(_ closure: (_ make: ConstraintMaker) -> Void) -> [Constraint] { return self.snp.prepareConstraints(closure) } - @available(*, deprecated, message:"Use newer snp.* syntax.") + @available(*, deprecated, renamed:"snp.makeConstraints(_:)") func snp_makeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { self.snp.makeConstraints(closure) } - @available(*, deprecated, message:"Use newer snp.* syntax.") + @available(*, deprecated, renamed:"snp.remakeConstraints(_:)") func snp_remakeConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { self.snp.remakeConstraints(closure) } - @available(*, deprecated, message:"Use newer snp.* syntax.") + @available(*, deprecated, renamed:"snp.updateConstraints(_:)") func snp_updateConstraints(_ closure: (_ make: ConstraintMaker) -> Void) { self.snp.updateConstraints(closure) } - @available(*, deprecated, message:"Use newer snp.* syntax.") + @available(*, deprecated, renamed:"snp.removeConstraints()") func snp_removeConstraints() { self.snp.removeConstraints() } From d592d1d9bece90c9b9c1b29b7b3d8d42e60715a4 Mon Sep 17 00:00:00 2001 From: pushp1989 <54930194+pushp1989@users.noreply.github.com> Date: Wed, 27 Nov 2019 15:57:13 +0530 Subject: [PATCH 40/57] Migrate to Xcode 11 and updated travis.yml (#629) * Migrate to Xcode 11 and updated travis.yml * Travis to support Xcode 11 --- .travis.yml | 2 +- SnapKit.xcodeproj/project.pbxproj | 7 +++--- .../xcshareddata/xcschemes/SnapKit.xcscheme | 24 ++++++++----------- 3 files changed, 15 insertions(+), 18 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4997cc4..6a9557e 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,5 @@ language: objective-c -osx_image: xcode10.2 +osx_image: xcode11 env: - ACTION=test PLATFORM=Mac DESTINATION='platform=macOS' diff --git a/SnapKit.xcodeproj/project.pbxproj b/SnapKit.xcodeproj/project.pbxproj index ec9c269..737b3e7 100644 --- a/SnapKit.xcodeproj/project.pbxproj +++ b/SnapKit.xcodeproj/project.pbxproj @@ -311,7 +311,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0720; - LastUpgradeCheck = 1000; + LastUpgradeCheck = 1100; ORGANIZATIONNAME = "SnapKit Team"; TargetAttributes = { EEBCC9D719CC627D0083B827 = { @@ -327,10 +327,9 @@ }; buildConfigurationList = DDC9FD901981B4DD009612C7 /* Build configuration list for PBXProject "SnapKit" */; compatibilityVersion = "Xcode 3.2"; - developmentRegion = English; + developmentRegion = en; hasScannedForEncodings = 0; knownRegions = ( - English, en, Base, ); @@ -421,6 +420,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; @@ -480,6 +480,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; diff --git a/SnapKit.xcodeproj/xcshareddata/xcschemes/SnapKit.xcscheme b/SnapKit.xcodeproj/xcshareddata/xcschemes/SnapKit.xcscheme index 48ec452..5532fe0 100644 --- a/SnapKit.xcodeproj/xcshareddata/xcschemes/SnapKit.xcscheme +++ b/SnapKit.xcodeproj/xcshareddata/xcschemes/SnapKit.xcscheme @@ -1,6 +1,6 @@ + + + + @@ -39,17 +48,6 @@ - - - - - - - - Date: Wed, 27 Nov 2019 11:28:29 +0100 Subject: [PATCH 42/57] Add test assert to unit test testCanSetLabel. (#625) --- Tests/SnapKitTests/Tests.swift | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Tests/SnapKitTests/Tests.swift b/Tests/SnapKitTests/Tests.swift index acf48aa..eaaf231 100644 --- a/Tests/SnapKitTests/Tests.swift +++ b/Tests/SnapKitTests/Tests.swift @@ -736,6 +736,8 @@ class SnapKitTests: XCTestCase { func testCanSetLabel() { self.container.snp.setLabel("Hello World") + + XCTAssertEqual(self.container.snp.label(), "Hello World") } func testPriorityShortcuts() { From dfe862da48f7b527309151d8b5f221f657fc7d50 Mon Sep 17 00:00:00 2001 From: "Wang, Chi" Date: Wed, 8 Jul 2020 06:52:57 +0800 Subject: [PATCH 43/57] Add back support for OS X 10.11 (#645) --- Package.swift | 2 +- SnapKit.podspec | 2 +- SnapKit.xcodeproj/project.pbxproj | 8 ++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Package.swift b/Package.swift index fb37579..8509cbc 100644 --- a/Package.swift +++ b/Package.swift @@ -29,7 +29,7 @@ let package = Package( name: "SnapKit", platforms: [ .iOS(.v10), - .macOS(.v10_12), + .macOS(.v10_11), .tvOS(.v10) ], products: [ diff --git a/SnapKit.podspec b/SnapKit.podspec index 7f99095..a3e868c 100644 --- a/SnapKit.podspec +++ b/SnapKit.podspec @@ -9,7 +9,7 @@ Pod::Spec.new do |s| s.source = { :git => 'https://github.com/SnapKit/SnapKit.git', :tag => '5.0.1' } s.ios.deployment_target = '10.0' - s.osx.deployment_target = '10.12' + s.osx.deployment_target = '10.11' s.tvos.deployment_target = '10.0' s.source_files = 'Source/*.swift' diff --git a/SnapKit.xcodeproj/project.pbxproj b/SnapKit.xcodeproj/project.pbxproj index 737b3e7..d7f51f4 100644 --- a/SnapKit.xcodeproj/project.pbxproj +++ b/SnapKit.xcodeproj/project.pbxproj @@ -538,7 +538,7 @@ INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.12; + MACOSX_DEPLOYMENT_TARGET = 10.11; PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_BUNDLE_PACKAGE_TYPE = FMWK; PRODUCT_NAME = SnapKit; @@ -561,7 +561,7 @@ INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.12; + MACOSX_DEPLOYMENT_TARGET = 10.11; PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_BUNDLE_PACKAGE_TYPE = FMWK; PRODUCT_NAME = SnapKit; @@ -580,7 +580,7 @@ INFOPLIST_FILE = "$(SRCROOT)/Tests/SnapKitTests/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks @loader_path/../Frameworks @executable_path/../Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.12; + MACOSX_DEPLOYMENT_TARGET = 10.11; PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_VERSION = 4.2; @@ -595,7 +595,7 @@ INFOPLIST_FILE = "$(SRCROOT)/Tests/SnapKitTests/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks @loader_path/../Frameworks @executable_path/../Frameworks"; - MACOSX_DEPLOYMENT_TARGET = 10.12; + MACOSX_DEPLOYMENT_TARGET = 10.11; PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.$(PRODUCT_NAME:rfc1034identifier)"; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; From 35e8835a6b0ea06f6cd561e1e5ee807f7bb104cd Mon Sep 17 00:00:00 2001 From: Roman Podymov Date: Wed, 8 Jul 2020 00:53:40 +0200 Subject: [PATCH 44/57] Use << for ConstraintAttributes options (#659) * Use << for ConstraintAttributes options * iPhone 6s is not supported by the latest Xcode --- .travis.yml | 2 +- Source/ConstraintAttributes.swift | 88 +++++++++++++++---------------- 2 files changed, 45 insertions(+), 45 deletions(-) diff --git a/.travis.yml b/.travis.yml index 6a9557e..1cfdf13 100644 --- a/.travis.yml +++ b/.travis.yml @@ -3,7 +3,7 @@ osx_image: xcode11 env: - 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 8' - ACTION=test PLATFORM=tvOS DESTINATION='platform=tvOS Simulator,name=Apple TV 4K (at 1080p)' script: diff --git a/Source/ConstraintAttributes.swift b/Source/ConstraintAttributes.swift index 5879c1a..408308b 100644 --- a/Source/ConstraintAttributes.swift +++ b/Source/ConstraintAttributes.swift @@ -56,65 +56,65 @@ internal struct ConstraintAttributes : OptionSet, ExpressibleByIntegerLiteral { // normal - internal static var none: ConstraintAttributes { return 0 } - internal static var left: ConstraintAttributes { return 1 } - internal static var top: ConstraintAttributes { return 2 } - internal static var right: ConstraintAttributes { return 4 } - internal static var bottom: ConstraintAttributes { return 8 } - internal static var leading: ConstraintAttributes { return 16 } - internal static var trailing: ConstraintAttributes { return 32 } - internal static var width: ConstraintAttributes { return 64 } - internal static var height: ConstraintAttributes { return 128 } - internal static var centerX: ConstraintAttributes { return 256 } - internal static var centerY: ConstraintAttributes { return 512 } - internal static var lastBaseline: ConstraintAttributes { return 1024 } + internal static let none: ConstraintAttributes = 0 + internal static let left: ConstraintAttributes = ConstraintAttributes(UInt(1) << 0) + internal static let top: ConstraintAttributes = ConstraintAttributes(UInt(1) << 1) + internal static let right: ConstraintAttributes = ConstraintAttributes(UInt(1) << 2) + internal static let bottom: ConstraintAttributes = ConstraintAttributes(UInt(1) << 3) + internal static let leading: ConstraintAttributes = ConstraintAttributes(UInt(1) << 4) + internal static let trailing: ConstraintAttributes = ConstraintAttributes(UInt(1) << 5) + internal static let width: ConstraintAttributes = ConstraintAttributes(UInt(1) << 6) + internal static let height: ConstraintAttributes = ConstraintAttributes(UInt(1) << 7) + internal static let centerX: ConstraintAttributes = ConstraintAttributes(UInt(1) << 8) + internal static let centerY: ConstraintAttributes = ConstraintAttributes(UInt(1) << 9) + internal static let lastBaseline: ConstraintAttributes = ConstraintAttributes(UInt(1) << 10) @available(iOS 8.0, OSX 10.11, *) - internal static var firstBaseline: ConstraintAttributes { return 2048 } - + internal static let firstBaseline: ConstraintAttributes = ConstraintAttributes(UInt(1) << 11) + @available(iOS 8.0, *) - internal static var leftMargin: ConstraintAttributes { return 4096 } - + internal static let leftMargin: ConstraintAttributes = ConstraintAttributes(UInt(1) << 12) + @available(iOS 8.0, *) - internal static var rightMargin: ConstraintAttributes { return 8192 } - + internal static let rightMargin: ConstraintAttributes = ConstraintAttributes(UInt(1) << 13) + @available(iOS 8.0, *) - internal static var topMargin: ConstraintAttributes { return 16384 } - + internal static let topMargin: ConstraintAttributes = ConstraintAttributes(UInt(1) << 14) + @available(iOS 8.0, *) - internal static var bottomMargin: ConstraintAttributes { return 32768 } - + internal static let bottomMargin: ConstraintAttributes = ConstraintAttributes(UInt(1) << 15) + @available(iOS 8.0, *) - internal static var leadingMargin: ConstraintAttributes { return 65536 } - + internal static let leadingMargin: ConstraintAttributes = ConstraintAttributes(UInt(1) << 16) + @available(iOS 8.0, *) - internal static var trailingMargin: ConstraintAttributes { return 131072 } - + internal static let trailingMargin: ConstraintAttributes = ConstraintAttributes(UInt(1) << 17) + @available(iOS 8.0, *) - internal static var centerXWithinMargins: ConstraintAttributes { return 262144 } - + internal static let centerXWithinMargins: ConstraintAttributes = ConstraintAttributes(UInt(1) << 18) + @available(iOS 8.0, *) - internal static var centerYWithinMargins: ConstraintAttributes { return 524288 } + internal static let centerYWithinMargins: ConstraintAttributes = ConstraintAttributes(UInt(1) << 19) // aggregates - internal static var edges: ConstraintAttributes { return 15 } - internal static var horizontalEdges: ConstraintAttributes { return 5 } - internal static var verticalEdges: ConstraintAttributes { return 10 } - internal static var directionalEdges: ConstraintAttributes { return 58 } - internal static var directionalHorizontalEdges: ConstraintAttributes { return 48 } - internal static var directionalVerticalEdges: ConstraintAttributes { return 10 } - internal static var size: ConstraintAttributes { return 192 } - internal static var center: ConstraintAttributes { return 768 } - - @available(iOS 8.0, *) - internal static var margins: ConstraintAttributes { return 61440 } - - @available(iOS 8.0, *) - internal static var directionalMargins: ConstraintAttributes { return 245760 } + internal static let edges: ConstraintAttributes = [.horizontalEdges, .verticalEdges] + internal static let horizontalEdges: ConstraintAttributes = [.left, .right] + internal static let verticalEdges: ConstraintAttributes = [.top, .bottom] + internal static let directionalEdges: ConstraintAttributes = [.directionalHorizontalEdges, .directionalVerticalEdges] + internal static let directionalHorizontalEdges: ConstraintAttributes = [.leading, .trailing] + internal static let directionalVerticalEdges: ConstraintAttributes = [.top, .bottom] + internal static let size: ConstraintAttributes = [.width, .height] + internal static let center: ConstraintAttributes = [.centerX, .centerY] @available(iOS 8.0, *) - internal static var centerWithinMargins: ConstraintAttributes { return 786432 } + internal static let margins: ConstraintAttributes = [.leftMargin, .topMargin, .rightMargin, .bottomMargin] + + @available(iOS 8.0, *) + internal static let directionalMargins: ConstraintAttributes = [.leadingMargin, .topMargin, .trailingMargin, .bottomMargin] + + @available(iOS 8.0, *) + internal static let centerWithinMargins: ConstraintAttributes = [.centerXWithinMargins, .centerYWithinMargins] internal var layoutAttributes:[LayoutAttribute] { var attrs = [LayoutAttribute]() From 4cac0e9ac1874de8b2062ecb8cb5b31a6e1543e5 Mon Sep 17 00:00:00 2001 From: wotjd Date: Wed, 8 Jul 2020 07:57:32 +0900 Subject: [PATCH 45/57] Add method getting constraint with closure to ConstraintMakerRelatable (#663) * add ConstraintMakerRelatable extension * fix fatalError message Co-authored-by: Jimi --- SnapKit.xcodeproj/project.pbxproj | 4 ++ .../ConstraintMakerRelatable+Extensions.swift | 57 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 Source/ConstraintMakerRelatable+Extensions.swift diff --git a/SnapKit.xcodeproj/project.pbxproj b/SnapKit.xcodeproj/project.pbxproj index d7f51f4..b38af4e 100644 --- a/SnapKit.xcodeproj/project.pbxproj +++ b/SnapKit.xcodeproj/project.pbxproj @@ -8,6 +8,7 @@ /* Begin PBXBuildFile section */ 2DBA080E1F1FAD66001CFED4 /* Typealiases.swift in Sources */ = {isa = PBXBuildFile; fileRef = 2DBA080D1F1FAD66001CFED4 /* Typealiases.swift */; }; + 3CA7D6C224592D4D005E10C2 /* ConstraintMakerRelatable+Extensions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3CA7D6C124592D4D005E10C2 /* ConstraintMakerRelatable+Extensions.swift */; }; 7E1CB2AE227BB5520066B6C0 /* ConstraintDirectionalInsetTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E1CB2AD227BB5520066B6C0 /* ConstraintDirectionalInsetTarget.swift */; }; 7E1CB2B0227BBDF70066B6C0 /* ConstraintDirectionalInsets.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E1CB2AF227BBDF70066B6C0 /* ConstraintDirectionalInsets.swift */; }; EE235F5F1C5785BC00C08960 /* Debugging.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235F5E1C5785BC00C08960 /* Debugging.swift */; }; @@ -50,6 +51,7 @@ /* Begin PBXFileReference section */ 2DBA080D1F1FAD66001CFED4 /* Typealiases.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Typealiases.swift; sourceTree = ""; }; + 3CA7D6C124592D4D005E10C2 /* ConstraintMakerRelatable+Extensions.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "ConstraintMakerRelatable+Extensions.swift"; sourceTree = ""; }; 537DCE9A1C35CD4100B5B899 /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = Platforms/AppleTVOS.platform/Developer/SDKs/AppleTVOS9.1.sdk/System/Library/Frameworks/UIKit.framework; sourceTree = DEVELOPER_DIR; }; 7E1CB2AD227BB5520066B6C0 /* ConstraintDirectionalInsetTarget.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConstraintDirectionalInsetTarget.swift; sourceTree = ""; }; 7E1CB2AF227BBDF70066B6C0 /* ConstraintDirectionalInsets.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ConstraintDirectionalInsets.swift; sourceTree = ""; }; @@ -139,6 +141,7 @@ EE235FC61C5785E200C08960 /* ConstraintView+Extensions.swift */, EEF68FAF1D784FB100980C26 /* ConstraintLayoutGuide+Extensions.swift */, EEF68FB31D784FBA00980C26 /* UILayoutSupport+Extensions.swift */, + 3CA7D6C124592D4D005E10C2 /* ConstraintMakerRelatable+Extensions.swift */, ); name = Extensions; sourceTree = ""; @@ -399,6 +402,7 @@ EE235FC01C5785DC00C08960 /* ConstraintViewDSL.swift in Sources */, EE235F5F1C5785BC00C08960 /* Debugging.swift in Sources */, EE235FC31C5785DC00C08960 /* ConstraintLayoutSupportDSL.swift in Sources */, + 3CA7D6C224592D4D005E10C2 /* ConstraintMakerRelatable+Extensions.swift in Sources */, EE235F7F1C5785C600C08960 /* ConstraintRelation.swift in Sources */, EEF68FB41D784FBA00980C26 /* UILayoutSupport+Extensions.swift in Sources */, EE235F701C5785C600C08960 /* ConstraintDescription.swift in Sources */, diff --git a/Source/ConstraintMakerRelatable+Extensions.swift b/Source/ConstraintMakerRelatable+Extensions.swift new file mode 100644 index 0000000..63100d7 --- /dev/null +++ b/Source/ConstraintMakerRelatable+Extensions.swift @@ -0,0 +1,57 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + + +extension ConstraintMakerRelatable { + + @discardableResult + public func equalToSuperview(_ closure: (ConstraintView) -> T, _ file: String = #file, line: UInt = #line) -> ConstraintMakerEditable { + guard let other = self.description.item.superview else { + fatalError("Expected superview but found nil when attempting make constraint `equalToSuperview`.") + } + return self.relatedTo(closure(other), relation: .equal, file: file, line: line) + } + + @discardableResult + public func lessThanOrEqualToSuperview(_ closure: (ConstraintView) -> T, _ file: String = #file, line: UInt = #line) -> ConstraintMakerEditable { + guard let other = self.description.item.superview else { + fatalError("Expected superview but found nil when attempting make constraint `lessThanOrEqualToSuperview`.") + } + return self.relatedTo(closure(other), relation: .lessThanOrEqual, file: file, line: line) + } + + @discardableResult + public func greaterThanOrEqualTo(_ closure: (ConstraintView) -> T, _ file: String = #file, line: UInt = #line) -> ConstraintMakerEditable { + guard let other = self.description.item.superview else { + fatalError("Expected superview but found nil when attempting make constraint `greaterThanOrEqualToSuperview`.") + } + return self.relatedTo(closure(other), relation: .greaterThanOrEqual, file: file, line: line) + } + +} From 18608ead653bfe1e05e3d1f6fb6d34f62cec49bd Mon Sep 17 00:00:00 2001 From: Robert Payne Date: Fri, 25 Sep 2020 15:27:40 +1200 Subject: [PATCH 46/57] Xcode 12 and SwiftPM enhancements --- Package.swift | 2 +- SnapKit.xcodeproj/project.pbxproj | 38 +++++++++---------- .../xcshareddata/xcschemes/SnapKit.xcscheme | 2 +- Source/SnapKit.h | 27 ------------- {Source => Sources}/Constraint.swift | 0 .../ConstraintAttributes.swift | 0 {Source => Sources}/ConstraintConfig.swift | 0 .../ConstraintConstantTarget.swift | 0 {Source => Sources}/ConstraintDSL.swift | 0 .../ConstraintDescription.swift | 0 .../ConstraintDirectionalInsetTarget.swift | 0 .../ConstraintDirectionalInsets.swift | 0 .../ConstraintInsetTarget.swift | 0 {Source => Sources}/ConstraintInsets.swift | 0 {Source => Sources}/ConstraintItem.swift | 0 .../ConstraintLayoutGuide+Extensions.swift | 0 .../ConstraintLayoutGuide.swift | 0 .../ConstraintLayoutGuideDSL.swift | 0 .../ConstraintLayoutSupport.swift | 0 .../ConstraintLayoutSupportDSL.swift | 0 {Source => Sources}/ConstraintMaker.swift | 0 .../ConstraintMakerEditable.swift | 0 .../ConstraintMakerExtendable.swift | 0 .../ConstraintMakerFinalizable.swift | 0 .../ConstraintMakerPriortizable.swift | 0 .../ConstraintMakerRelatable+Extensions.swift | 0 .../ConstraintMakerRelatable.swift | 0 .../ConstraintMultiplierTarget.swift | 0 .../ConstraintOffsetTarget.swift | 0 {Source => Sources}/ConstraintPriority.swift | 0 .../ConstraintPriorityTarget.swift | 0 .../ConstraintRelatableTarget.swift | 0 {Source => Sources}/ConstraintRelation.swift | 0 .../ConstraintView+Extensions.swift | 0 {Source => Sources}/ConstraintView.swift | 0 {Source => Sources}/ConstraintViewDSL.swift | 0 {Source => Sources}/Debugging.swift | 0 {Source => Sources}/LayoutConstraint.swift | 0 .../LayoutConstraintItem.swift | 0 {Source => Sources}/Typealiases.swift | 0 .../UILayoutSupport+Extensions.swift | 0 {Source => Supporting Files}/Info.plist | 0 42 files changed, 20 insertions(+), 49 deletions(-) delete mode 100644 Source/SnapKit.h rename {Source => Sources}/Constraint.swift (100%) rename {Source => Sources}/ConstraintAttributes.swift (100%) rename {Source => Sources}/ConstraintConfig.swift (100%) rename {Source => Sources}/ConstraintConstantTarget.swift (100%) rename {Source => Sources}/ConstraintDSL.swift (100%) rename {Source => Sources}/ConstraintDescription.swift (100%) rename {Source => Sources}/ConstraintDirectionalInsetTarget.swift (100%) rename {Source => Sources}/ConstraintDirectionalInsets.swift (100%) rename {Source => Sources}/ConstraintInsetTarget.swift (100%) rename {Source => Sources}/ConstraintInsets.swift (100%) rename {Source => Sources}/ConstraintItem.swift (100%) rename {Source => Sources}/ConstraintLayoutGuide+Extensions.swift (100%) rename {Source => Sources}/ConstraintLayoutGuide.swift (100%) rename {Source => Sources}/ConstraintLayoutGuideDSL.swift (100%) rename {Source => Sources}/ConstraintLayoutSupport.swift (100%) rename {Source => Sources}/ConstraintLayoutSupportDSL.swift (100%) rename {Source => Sources}/ConstraintMaker.swift (100%) rename {Source => Sources}/ConstraintMakerEditable.swift (100%) rename {Source => Sources}/ConstraintMakerExtendable.swift (100%) rename {Source => Sources}/ConstraintMakerFinalizable.swift (100%) rename {Source => Sources}/ConstraintMakerPriortizable.swift (100%) rename {Source => Sources}/ConstraintMakerRelatable+Extensions.swift (100%) rename {Source => Sources}/ConstraintMakerRelatable.swift (100%) rename {Source => Sources}/ConstraintMultiplierTarget.swift (100%) rename {Source => Sources}/ConstraintOffsetTarget.swift (100%) rename {Source => Sources}/ConstraintPriority.swift (100%) rename {Source => Sources}/ConstraintPriorityTarget.swift (100%) rename {Source => Sources}/ConstraintRelatableTarget.swift (100%) rename {Source => Sources}/ConstraintRelation.swift (100%) rename {Source => Sources}/ConstraintView+Extensions.swift (100%) rename {Source => Sources}/ConstraintView.swift (100%) rename {Source => Sources}/ConstraintViewDSL.swift (100%) rename {Source => Sources}/Debugging.swift (100%) rename {Source => Sources}/LayoutConstraint.swift (100%) rename {Source => Sources}/LayoutConstraintItem.swift (100%) rename {Source => Sources}/Typealiases.swift (100%) rename {Source => Sources}/UILayoutSupport+Extensions.swift (100%) rename {Source => Supporting Files}/Info.plist (100%) diff --git a/Package.swift b/Package.swift index 8509cbc..7320cd8 100644 --- a/Package.swift +++ b/Package.swift @@ -36,7 +36,7 @@ let package = Package( .library(name: "SnapKit", targets: ["SnapKit"]), ], targets: [ - .target(name: "SnapKit", path: "Source"), + .target(name: "SnapKit", path: "Sources"), .testTarget(name: "SnapKitTests", dependencies: ["SnapKit"]), ], swiftLanguageVersions: [ diff --git a/SnapKit.xcodeproj/project.pbxproj b/SnapKit.xcodeproj/project.pbxproj index b38af4e..da040da 100644 --- a/SnapKit.xcodeproj/project.pbxproj +++ b/SnapKit.xcodeproj/project.pbxproj @@ -39,7 +39,6 @@ EE4910991B19A40200A54F1F /* SnapKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = EEBCC9D819CC627D0083B827 /* SnapKit.framework */; }; EE6087751E4F133E0029CF84 /* ConstraintPriority.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE6087741E4F133E0029CF84 /* ConstraintPriority.swift */; }; EE6898CB1DA7B3A100D47F33 /* LayoutConstraintItem.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE6898CA1DA7B3A100D47F33 /* LayoutConstraintItem.swift */; }; - EECDB3741AC0C9B6006BBC11 /* SnapKit.h in Headers */ = {isa = PBXBuildFile; fileRef = EECDB3661AC0C95C006BBC11 /* SnapKit.h */; settings = {ATTRIBUTES = (Public, ); }; }; EECDB3931AC0CB52006BBC11 /* Tests.swift in Sources */ = {isa = PBXBuildFile; fileRef = EECDB36A1AC0C95C006BBC11 /* Tests.swift */; }; EEF68F9E1D78492400980C26 /* ConstraintLayoutGuideDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF68F9D1D78492400980C26 /* ConstraintLayoutGuideDSL.swift */; }; EEF68FA61D784A5300980C26 /* ConstraintDSL.swift in Sources */ = {isa = PBXBuildFile; fileRef = EEF68FA51D784A5300980C26 /* ConstraintDSL.swift */; }; @@ -82,12 +81,11 @@ EE235FC61C5785E200C08960 /* ConstraintView+Extensions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "ConstraintView+Extensions.swift"; sourceTree = ""; }; EE6087741E4F133E0029CF84 /* ConstraintPriority.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintPriority.swift; sourceTree = ""; }; EE6898CA1DA7B3A100D47F33 /* LayoutConstraintItem.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = LayoutConstraintItem.swift; sourceTree = ""; }; + EE6DB559251D9A6B00E0C374 /* Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; EE94F6081AC0F10A008767FF /* UIKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = UIKit.framework; path = System/Library/Frameworks/UIKit.framework; sourceTree = SDKROOT; }; EE94F60A1AC0F10F008767FF /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.10.sdk/System/Library/Frameworks/AppKit.framework; sourceTree = DEVELOPER_DIR; }; EEBCC9D819CC627D0083B827 /* SnapKit.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = SnapKit.framework; sourceTree = BUILT_PRODUCTS_DIR; }; EEBCC9E219CC627E0083B827 /* SnapKit Tests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = "SnapKit Tests.xctest"; sourceTree = BUILT_PRODUCTS_DIR; }; - EECDB3641AC0C95C006BBC11 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; - EECDB3661AC0C95C006BBC11 /* SnapKit.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = SnapKit.h; sourceTree = ""; }; EECDB3691AC0C95C006BBC11 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; name = Info.plist; path = SnapKitTests/Info.plist; sourceTree = ""; }; EECDB36A1AC0C95C006BBC11 /* Tests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; name = Tests.swift; path = SnapKitTests/Tests.swift; sourceTree = ""; }; EEF68F9D1D78492400980C26 /* ConstraintLayoutGuideDSL.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintLayoutGuideDSL.swift; sourceTree = ""; }; @@ -120,7 +118,8 @@ DDC9FD8C1981B4DD009612C7 = { isa = PBXGroup; children = ( - EECDB35D1AC0C95C006BBC11 /* Source */, + EE6DB557251D9A6B00E0C374 /* Supporting Files */, + EECDB35D1AC0C95C006BBC11 /* Sources */, EE94F60C1AC0F113008767FF /* Frameworks */, DDC9FD961981B4DD009612C7 /* Products */, ); @@ -214,6 +213,14 @@ name = Debugging; sourceTree = ""; }; + EE6DB557251D9A6B00E0C374 /* Supporting Files */ = { + isa = PBXGroup; + children = ( + EE6DB559251D9A6B00E0C374 /* Info.plist */, + ); + path = "Supporting Files"; + sourceTree = ""; + }; EE94F60C1AC0F113008767FF /* Frameworks */ = { isa = PBXGroup; children = ( @@ -224,20 +231,18 @@ name = Frameworks; sourceTree = ""; }; - EECDB35D1AC0C95C006BBC11 /* Source */ = { + EECDB35D1AC0C95C006BBC11 /* Sources */ = { isa = PBXGroup; children = ( - EECDB3661AC0C95C006BBC11 /* SnapKit.h */, EE235F581C57858700C08960 /* Extensions */, EE235F591C57859200C08960 /* DSLs */, EE235F5A1C57859900C08960 /* Maker */, EE235F5B1C57859E00C08960 /* Targets */, EE235F5C1C5785A400C08960 /* Models */, EE235F5D1C5785AC00C08960 /* Debugging */, - EECDB36B1AC0C967006BBC11 /* Supporting Files */, EECDB3681AC0C95C006BBC11 /* Tests */, ); - path = Source; + path = Sources; sourceTree = ""; }; EECDB3681AC0C95C006BBC11 /* Tests */ = { @@ -250,14 +255,6 @@ path = ../Tests; sourceTree = ""; }; - EECDB36B1AC0C967006BBC11 /* Supporting Files */ = { - isa = PBXGroup; - children = ( - EECDB3641AC0C95C006BBC11 /* Info.plist */, - ); - name = "Supporting Files"; - sourceTree = ""; - }; /* End PBXGroup section */ /* Begin PBXHeadersBuildPhase section */ @@ -265,7 +262,6 @@ isa = PBXHeadersBuildPhase; buildActionMask = 2147483647; files = ( - EECDB3741AC0C9B6006BBC11 /* SnapKit.h in Headers */, ); runOnlyForDeploymentPostprocessing = 0; }; @@ -314,7 +310,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0720; - LastUpgradeCheck = 1100; + LastUpgradeCheck = 1200; ORGANIZATIONNAME = "SnapKit Team"; TargetAttributes = { EEBCC9D719CC627D0083B827 = { @@ -443,6 +439,7 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -503,6 +500,7 @@ CLANG_WARN_OBJC_IMPLICIT_RETAIN_SELF = YES; CLANG_WARN_OBJC_LITERAL_CONVERSION = YES; CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR; + CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; CLANG_WARN_STRICT_PROTOTYPES = YES; CLANG_WARN_SUSPICIOUS_MOVE = YES; @@ -539,7 +537,7 @@ CURRENT_PROJECT_VERSION = 1.0.0; DEFINES_MODULE = YES; DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist"; + INFOPLIST_FILE = "$(SRCROOT)/Supporting Files/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.11; @@ -562,7 +560,7 @@ CURRENT_PROJECT_VERSION = 1.0.0; DEFINES_MODULE = YES; DYLIB_INSTALL_NAME_BASE = "@rpath"; - INFOPLIST_FILE = "$(SRCROOT)/Source/Info.plist"; + INFOPLIST_FILE = "$(SRCROOT)/Supporting Files/Info.plist"; IPHONEOS_DEPLOYMENT_TARGET = 10.0; LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; MACOSX_DEPLOYMENT_TARGET = 10.11; diff --git a/SnapKit.xcodeproj/xcshareddata/xcschemes/SnapKit.xcscheme b/SnapKit.xcodeproj/xcshareddata/xcschemes/SnapKit.xcscheme index 5532fe0..0f34b8e 100644 --- a/SnapKit.xcodeproj/xcshareddata/xcschemes/SnapKit.xcscheme +++ b/SnapKit.xcodeproj/xcshareddata/xcschemes/SnapKit.xcscheme @@ -1,6 +1,6 @@ - -FOUNDATION_EXPORT double SnapKitVersionNumber; -FOUNDATION_EXPORT const unsigned char SnapKitVersionString[]; \ No newline at end of file diff --git a/Source/Constraint.swift b/Sources/Constraint.swift similarity index 100% rename from Source/Constraint.swift rename to Sources/Constraint.swift diff --git a/Source/ConstraintAttributes.swift b/Sources/ConstraintAttributes.swift similarity index 100% rename from Source/ConstraintAttributes.swift rename to Sources/ConstraintAttributes.swift diff --git a/Source/ConstraintConfig.swift b/Sources/ConstraintConfig.swift similarity index 100% rename from Source/ConstraintConfig.swift rename to Sources/ConstraintConfig.swift diff --git a/Source/ConstraintConstantTarget.swift b/Sources/ConstraintConstantTarget.swift similarity index 100% rename from Source/ConstraintConstantTarget.swift rename to Sources/ConstraintConstantTarget.swift diff --git a/Source/ConstraintDSL.swift b/Sources/ConstraintDSL.swift similarity index 100% rename from Source/ConstraintDSL.swift rename to Sources/ConstraintDSL.swift diff --git a/Source/ConstraintDescription.swift b/Sources/ConstraintDescription.swift similarity index 100% rename from Source/ConstraintDescription.swift rename to Sources/ConstraintDescription.swift diff --git a/Source/ConstraintDirectionalInsetTarget.swift b/Sources/ConstraintDirectionalInsetTarget.swift similarity index 100% rename from Source/ConstraintDirectionalInsetTarget.swift rename to Sources/ConstraintDirectionalInsetTarget.swift diff --git a/Source/ConstraintDirectionalInsets.swift b/Sources/ConstraintDirectionalInsets.swift similarity index 100% rename from Source/ConstraintDirectionalInsets.swift rename to Sources/ConstraintDirectionalInsets.swift diff --git a/Source/ConstraintInsetTarget.swift b/Sources/ConstraintInsetTarget.swift similarity index 100% rename from Source/ConstraintInsetTarget.swift rename to Sources/ConstraintInsetTarget.swift diff --git a/Source/ConstraintInsets.swift b/Sources/ConstraintInsets.swift similarity index 100% rename from Source/ConstraintInsets.swift rename to Sources/ConstraintInsets.swift diff --git a/Source/ConstraintItem.swift b/Sources/ConstraintItem.swift similarity index 100% rename from Source/ConstraintItem.swift rename to Sources/ConstraintItem.swift diff --git a/Source/ConstraintLayoutGuide+Extensions.swift b/Sources/ConstraintLayoutGuide+Extensions.swift similarity index 100% rename from Source/ConstraintLayoutGuide+Extensions.swift rename to Sources/ConstraintLayoutGuide+Extensions.swift diff --git a/Source/ConstraintLayoutGuide.swift b/Sources/ConstraintLayoutGuide.swift similarity index 100% rename from Source/ConstraintLayoutGuide.swift rename to Sources/ConstraintLayoutGuide.swift diff --git a/Source/ConstraintLayoutGuideDSL.swift b/Sources/ConstraintLayoutGuideDSL.swift similarity index 100% rename from Source/ConstraintLayoutGuideDSL.swift rename to Sources/ConstraintLayoutGuideDSL.swift diff --git a/Source/ConstraintLayoutSupport.swift b/Sources/ConstraintLayoutSupport.swift similarity index 100% rename from Source/ConstraintLayoutSupport.swift rename to Sources/ConstraintLayoutSupport.swift diff --git a/Source/ConstraintLayoutSupportDSL.swift b/Sources/ConstraintLayoutSupportDSL.swift similarity index 100% rename from Source/ConstraintLayoutSupportDSL.swift rename to Sources/ConstraintLayoutSupportDSL.swift diff --git a/Source/ConstraintMaker.swift b/Sources/ConstraintMaker.swift similarity index 100% rename from Source/ConstraintMaker.swift rename to Sources/ConstraintMaker.swift diff --git a/Source/ConstraintMakerEditable.swift b/Sources/ConstraintMakerEditable.swift similarity index 100% rename from Source/ConstraintMakerEditable.swift rename to Sources/ConstraintMakerEditable.swift diff --git a/Source/ConstraintMakerExtendable.swift b/Sources/ConstraintMakerExtendable.swift similarity index 100% rename from Source/ConstraintMakerExtendable.swift rename to Sources/ConstraintMakerExtendable.swift diff --git a/Source/ConstraintMakerFinalizable.swift b/Sources/ConstraintMakerFinalizable.swift similarity index 100% rename from Source/ConstraintMakerFinalizable.swift rename to Sources/ConstraintMakerFinalizable.swift diff --git a/Source/ConstraintMakerPriortizable.swift b/Sources/ConstraintMakerPriortizable.swift similarity index 100% rename from Source/ConstraintMakerPriortizable.swift rename to Sources/ConstraintMakerPriortizable.swift diff --git a/Source/ConstraintMakerRelatable+Extensions.swift b/Sources/ConstraintMakerRelatable+Extensions.swift similarity index 100% rename from Source/ConstraintMakerRelatable+Extensions.swift rename to Sources/ConstraintMakerRelatable+Extensions.swift diff --git a/Source/ConstraintMakerRelatable.swift b/Sources/ConstraintMakerRelatable.swift similarity index 100% rename from Source/ConstraintMakerRelatable.swift rename to Sources/ConstraintMakerRelatable.swift diff --git a/Source/ConstraintMultiplierTarget.swift b/Sources/ConstraintMultiplierTarget.swift similarity index 100% rename from Source/ConstraintMultiplierTarget.swift rename to Sources/ConstraintMultiplierTarget.swift diff --git a/Source/ConstraintOffsetTarget.swift b/Sources/ConstraintOffsetTarget.swift similarity index 100% rename from Source/ConstraintOffsetTarget.swift rename to Sources/ConstraintOffsetTarget.swift diff --git a/Source/ConstraintPriority.swift b/Sources/ConstraintPriority.swift similarity index 100% rename from Source/ConstraintPriority.swift rename to Sources/ConstraintPriority.swift diff --git a/Source/ConstraintPriorityTarget.swift b/Sources/ConstraintPriorityTarget.swift similarity index 100% rename from Source/ConstraintPriorityTarget.swift rename to Sources/ConstraintPriorityTarget.swift diff --git a/Source/ConstraintRelatableTarget.swift b/Sources/ConstraintRelatableTarget.swift similarity index 100% rename from Source/ConstraintRelatableTarget.swift rename to Sources/ConstraintRelatableTarget.swift diff --git a/Source/ConstraintRelation.swift b/Sources/ConstraintRelation.swift similarity index 100% rename from Source/ConstraintRelation.swift rename to Sources/ConstraintRelation.swift diff --git a/Source/ConstraintView+Extensions.swift b/Sources/ConstraintView+Extensions.swift similarity index 100% rename from Source/ConstraintView+Extensions.swift rename to Sources/ConstraintView+Extensions.swift diff --git a/Source/ConstraintView.swift b/Sources/ConstraintView.swift similarity index 100% rename from Source/ConstraintView.swift rename to Sources/ConstraintView.swift diff --git a/Source/ConstraintViewDSL.swift b/Sources/ConstraintViewDSL.swift similarity index 100% rename from Source/ConstraintViewDSL.swift rename to Sources/ConstraintViewDSL.swift diff --git a/Source/Debugging.swift b/Sources/Debugging.swift similarity index 100% rename from Source/Debugging.swift rename to Sources/Debugging.swift diff --git a/Source/LayoutConstraint.swift b/Sources/LayoutConstraint.swift similarity index 100% rename from Source/LayoutConstraint.swift rename to Sources/LayoutConstraint.swift diff --git a/Source/LayoutConstraintItem.swift b/Sources/LayoutConstraintItem.swift similarity index 100% rename from Source/LayoutConstraintItem.swift rename to Sources/LayoutConstraintItem.swift diff --git a/Source/Typealiases.swift b/Sources/Typealiases.swift similarity index 100% rename from Source/Typealiases.swift rename to Sources/Typealiases.swift diff --git a/Source/UILayoutSupport+Extensions.swift b/Sources/UILayoutSupport+Extensions.swift similarity index 100% rename from Source/UILayoutSupport+Extensions.swift rename to Sources/UILayoutSupport+Extensions.swift diff --git a/Source/Info.plist b/Supporting Files/Info.plist similarity index 100% rename from Source/Info.plist rename to Supporting Files/Info.plist From 59e0e24f89144bf37e9718fac4e63085ee4fd24b Mon Sep 17 00:00:00 2001 From: Samuel Eshun Date: Fri, 25 Sep 2020 03:29:40 +0000 Subject: [PATCH 47/57] Update README to include SPM installation notes (#673) --- README.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/README.md b/README.md index ecc209c..8b19bd4 100644 --- a/README.md +++ b/README.md @@ -84,6 +84,20 @@ github "SnapKit/SnapKit" ~> 5.0.0 Run `carthage update` to build the framework and drag the built `SnapKit.framework` into your Xcode project. +### Swift Package Manager + +[Swift Package Manager](https://swift.org/package-manager/) is a tool for managing the distribution of Swift code. It’s integrated with the Swift build system to automate the process of downloading, compiling, and linking dependencies. + +> Xcode 11+ is required to build SnapKit using Swift Package Manager. + +To integrate SnapKit into your Xcode project using Swift Package Manager, add it to the dependencies value of your `Package.swift`: + +```swift +dependencies: [ + .package(url: "https://github.com/SnapKit/SnapKit.git", .upToNextMajor(from: "5.0.1")) +] +``` + ### Manually If you prefer not to use either of the aforementioned dependency managers, you can integrate SnapKit into your project manually. From 1d0160bce252aeb5c356e617cca2f9ec64449db1 Mon Sep 17 00:00:00 2001 From: Robert Payne Date: Fri, 25 Sep 2020 15:32:00 +1200 Subject: [PATCH 48/57] Fix typo --- SnapKit.xcodeproj/project.pbxproj | 8 +-- Sources/ConstraintMakerEditable.swift | 2 +- Sources/ConstraintMakerPrioritizable.swift | 70 ++++++++++++++++++++++ Sources/ConstraintMakerPriortizable.swift | 2 +- 4 files changed, 76 insertions(+), 6 deletions(-) create mode 100644 Sources/ConstraintMakerPrioritizable.swift diff --git a/SnapKit.xcodeproj/project.pbxproj b/SnapKit.xcodeproj/project.pbxproj index da040da..1f61efa 100644 --- a/SnapKit.xcodeproj/project.pbxproj +++ b/SnapKit.xcodeproj/project.pbxproj @@ -29,7 +29,7 @@ EE235FA31C5785CE00C08960 /* ConstraintInsetTarget.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235F931C5785CE00C08960 /* ConstraintInsetTarget.swift */; }; EE235FAC1C5785D400C08960 /* ConstraintMaker.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235FA61C5785D400C08960 /* ConstraintMaker.swift */; }; EE235FAF1C5785D400C08960 /* ConstraintMakerFinalizable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235FA71C5785D400C08960 /* ConstraintMakerFinalizable.swift */; }; - EE235FB21C5785D400C08960 /* ConstraintMakerPriortizable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235FA81C5785D400C08960 /* ConstraintMakerPriortizable.swift */; }; + EE235FB21C5785D400C08960 /* ConstraintMakerPrioritizable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235FA81C5785D400C08960 /* ConstraintMakerPrioritizable.swift */; }; EE235FB51C5785D400C08960 /* ConstraintMakerEditable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235FA91C5785D400C08960 /* ConstraintMakerEditable.swift */; }; EE235FB81C5785D400C08960 /* ConstraintMakerRelatable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235FAA1C5785D400C08960 /* ConstraintMakerRelatable.swift */; }; EE235FBB1C5785D400C08960 /* ConstraintMakerExtendable.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE235FAB1C5785D400C08960 /* ConstraintMakerExtendable.swift */; }; @@ -72,7 +72,7 @@ EE235F931C5785CE00C08960 /* ConstraintInsetTarget.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintInsetTarget.swift; sourceTree = ""; }; EE235FA61C5785D400C08960 /* ConstraintMaker.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintMaker.swift; sourceTree = ""; }; EE235FA71C5785D400C08960 /* ConstraintMakerFinalizable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintMakerFinalizable.swift; sourceTree = ""; }; - EE235FA81C5785D400C08960 /* ConstraintMakerPriortizable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintMakerPriortizable.swift; sourceTree = ""; }; + EE235FA81C5785D400C08960 /* ConstraintMakerPrioritizable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintMakerPrioritizable.swift; sourceTree = ""; }; EE235FA91C5785D400C08960 /* ConstraintMakerEditable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintMakerEditable.swift; sourceTree = ""; }; EE235FAA1C5785D400C08960 /* ConstraintMakerRelatable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintMakerRelatable.swift; sourceTree = ""; }; EE235FAB1C5785D400C08960 /* ConstraintMakerExtendable.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ConstraintMakerExtendable.swift; sourceTree = ""; }; @@ -161,7 +161,7 @@ children = ( EE235FA61C5785D400C08960 /* ConstraintMaker.swift */, EE235FA71C5785D400C08960 /* ConstraintMakerFinalizable.swift */, - EE235FA81C5785D400C08960 /* ConstraintMakerPriortizable.swift */, + EE235FA81C5785D400C08960 /* ConstraintMakerPrioritizable.swift */, EE235FA91C5785D400C08960 /* ConstraintMakerEditable.swift */, EE235FAA1C5785D400C08960 /* ConstraintMakerRelatable.swift */, EE235FAB1C5785D400C08960 /* ConstraintMakerExtendable.swift */, @@ -390,7 +390,7 @@ EE235F6D1C5785C600C08960 /* Constraint.swift in Sources */, EE235F791C5785C600C08960 /* ConstraintView.swift in Sources */, EE6898CB1DA7B3A100D47F33 /* LayoutConstraintItem.swift in Sources */, - EE235FB21C5785D400C08960 /* ConstraintMakerPriortizable.swift in Sources */, + EE235FB21C5785D400C08960 /* ConstraintMakerPrioritizable.swift in Sources */, EE235F8B1C5785C600C08960 /* LayoutConstraint.swift in Sources */, 7E1CB2B0227BBDF70066B6C0 /* ConstraintDirectionalInsets.swift in Sources */, EE235FA31C5785CE00C08960 /* ConstraintInsetTarget.swift in Sources */, diff --git a/Sources/ConstraintMakerEditable.swift b/Sources/ConstraintMakerEditable.swift index f768a17..4869bc2 100644 --- a/Sources/ConstraintMakerEditable.swift +++ b/Sources/ConstraintMakerEditable.swift @@ -28,7 +28,7 @@ #endif -public class ConstraintMakerEditable: ConstraintMakerPriortizable { +public class ConstraintMakerEditable: ConstraintMakerPrioritizable { @discardableResult public func multipliedBy(_ amount: ConstraintMultiplierTarget) -> ConstraintMakerEditable { diff --git a/Sources/ConstraintMakerPrioritizable.swift b/Sources/ConstraintMakerPrioritizable.swift new file mode 100644 index 0000000..5af5303 --- /dev/null +++ b/Sources/ConstraintMakerPrioritizable.swift @@ -0,0 +1,70 @@ +// +// SnapKit +// +// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +#if os(iOS) || os(tvOS) + import UIKit +#else + import AppKit +#endif + +@available(*, deprecated, message:"Use ConstraintMakerPrioritizable instead.") +public typealias ConstraintMakerPriortizable = ConstraintMakerPrioritizable + +public class ConstraintMakerPrioritizable: ConstraintMakerFinalizable { + + @discardableResult + public func priority(_ amount: ConstraintPriority) -> ConstraintMakerFinalizable { + self.description.priority = amount.value + return self + } + + @discardableResult + public func priority(_ amount: ConstraintPriorityTarget) -> ConstraintMakerFinalizable { + self.description.priority = amount + return self + } + + @available(*, deprecated, message:"Use priority(.required) instead.") + @discardableResult + public func priorityRequired() -> ConstraintMakerFinalizable { + return self.priority(.required) + } + + @available(*, deprecated, message:"Use priority(.high) instead.") + @discardableResult + public func priorityHigh() -> ConstraintMakerFinalizable { + return self.priority(.high) + } + + @available(*, deprecated, message:"Use priority(.medium) instead.") + @discardableResult + public func priorityMedium() -> ConstraintMakerFinalizable { + return self.priority(.medium) + } + + @available(*, deprecated, message:"Use priority(.low) instead.") + @discardableResult + public func priorityLow() -> ConstraintMakerFinalizable { + return self.priority(.low) + } +} diff --git a/Sources/ConstraintMakerPriortizable.swift b/Sources/ConstraintMakerPriortizable.swift index e0d452d..c5f8a30 100644 --- a/Sources/ConstraintMakerPriortizable.swift +++ b/Sources/ConstraintMakerPriortizable.swift @@ -28,7 +28,7 @@ #endif -public class ConstraintMakerPriortizable: ConstraintMakerFinalizable { +public class ConstraintMakerPrioritizable: ConstraintMakerFinalizable { @discardableResult public func priority(_ amount: ConstraintPriority) -> ConstraintMakerFinalizable { From f9dec4789465be27ff516218c94afd0aa229ee00 Mon Sep 17 00:00:00 2001 From: Robert Payne Date: Fri, 25 Sep 2020 16:00:30 +1200 Subject: [PATCH 49/57] Remove duplicate file --- .../contents.xcworkspacedata | 4 ++ Sources/ConstraintMakerPriortizable.swift | 68 ------------------- 2 files changed, 4 insertions(+), 68 deletions(-) create mode 100644 SnapKitPlayground.playground/playground.xcworkspace/contents.xcworkspacedata delete mode 100644 Sources/ConstraintMakerPriortizable.swift diff --git a/SnapKitPlayground.playground/playground.xcworkspace/contents.xcworkspacedata b/SnapKitPlayground.playground/playground.xcworkspace/contents.xcworkspacedata new file mode 100644 index 0000000..94b2795 --- /dev/null +++ b/SnapKitPlayground.playground/playground.xcworkspace/contents.xcworkspacedata @@ -0,0 +1,4 @@ + + + diff --git a/Sources/ConstraintMakerPriortizable.swift b/Sources/ConstraintMakerPriortizable.swift deleted file mode 100644 index c5f8a30..0000000 --- a/Sources/ConstraintMakerPriortizable.swift +++ /dev/null @@ -1,68 +0,0 @@ -// -// SnapKit -// -// Copyright (c) 2011-Present SnapKit Team - https://github.com/SnapKit -// -// Permission is hereby granted, free of charge, to any person obtaining a copy -// of this software and associated documentation files (the "Software"), to deal -// in the Software without restriction, including without limitation the rights -// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -// copies of the Software, and to permit persons to whom the Software is -// furnished to do so, subject to the following conditions: -// -// The above copyright notice and this permission notice shall be included in -// all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN -// THE SOFTWARE. - -#if os(iOS) || os(tvOS) - import UIKit -#else - import AppKit -#endif - - -public class ConstraintMakerPrioritizable: ConstraintMakerFinalizable { - - @discardableResult - public func priority(_ amount: ConstraintPriority) -> ConstraintMakerFinalizable { - self.description.priority = amount.value - return self - } - - @discardableResult - public func priority(_ amount: ConstraintPriorityTarget) -> ConstraintMakerFinalizable { - self.description.priority = amount - return self - } - - @available(*, deprecated, message:"Use priority(.required) instead.") - @discardableResult - public func priorityRequired() -> ConstraintMakerFinalizable { - return self.priority(.required) - } - - @available(*, deprecated, message:"Use priority(.high) instead.") - @discardableResult - public func priorityHigh() -> ConstraintMakerFinalizable { - return self.priority(.high) - } - - @available(*, deprecated, message:"Use priority(.medium) instead.") - @discardableResult - public func priorityMedium() -> ConstraintMakerFinalizable { - return self.priority(.medium) - } - - @available(*, deprecated, message:"Use priority(.low) instead.") - @discardableResult - public func priorityLow() -> ConstraintMakerFinalizable { - return self.priority(.low) - } -} From e5606bda4d00ff4569d3541cd487c07d84e9960e Mon Sep 17 00:00:00 2001 From: Amr Elghadban Date: Wed, 27 Jan 2021 14:59:55 +0400 Subject: [PATCH 50/57] xcodeproject configuration enhancement for localization (#584) Co-authored-by: AmrAngry --- SnapKit.xcodeproj/project.pbxproj | 2 +- SnapKit.xcodeproj/xcshareddata/xcschemes/SnapKit.xcscheme | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/SnapKit.xcodeproj/project.pbxproj b/SnapKit.xcodeproj/project.pbxproj index 1f61efa..4016319 100644 --- a/SnapKit.xcodeproj/project.pbxproj +++ b/SnapKit.xcodeproj/project.pbxproj @@ -310,7 +310,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0720; - LastUpgradeCheck = 1200; + LastUpgradeCheck = 1020; ORGANIZATIONNAME = "SnapKit Team"; TargetAttributes = { EEBCC9D719CC627D0083B827 = { diff --git a/SnapKit.xcodeproj/xcshareddata/xcschemes/SnapKit.xcscheme b/SnapKit.xcodeproj/xcshareddata/xcschemes/SnapKit.xcscheme index 0f34b8e..7c2a940 100644 --- a/SnapKit.xcodeproj/xcshareddata/xcschemes/SnapKit.xcscheme +++ b/SnapKit.xcodeproj/xcshareddata/xcschemes/SnapKit.xcscheme @@ -1,6 +1,6 @@ Date: Thu, 28 Jan 2021 00:01:36 +1300 Subject: [PATCH 51/57] Updates to project files --- SnapKit.xcodeproj/project.pbxproj | 2 +- SnapKit.xcodeproj/xcshareddata/xcschemes/SnapKit.xcscheme | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/SnapKit.xcodeproj/project.pbxproj b/SnapKit.xcodeproj/project.pbxproj index 4016319..2eb0793 100644 --- a/SnapKit.xcodeproj/project.pbxproj +++ b/SnapKit.xcodeproj/project.pbxproj @@ -310,7 +310,7 @@ isa = PBXProject; attributes = { LastSwiftUpdateCheck = 0720; - LastUpgradeCheck = 1020; + LastUpgradeCheck = 1230; ORGANIZATIONNAME = "SnapKit Team"; TargetAttributes = { EEBCC9D719CC627D0083B827 = { diff --git a/SnapKit.xcodeproj/xcshareddata/xcschemes/SnapKit.xcscheme b/SnapKit.xcodeproj/xcshareddata/xcschemes/SnapKit.xcscheme index 7c2a940..aa1d3af 100644 --- a/SnapKit.xcodeproj/xcshareddata/xcschemes/SnapKit.xcscheme +++ b/SnapKit.xcodeproj/xcshareddata/xcschemes/SnapKit.xcscheme @@ -1,6 +1,6 @@ Date: Wed, 21 Apr 2021 18:18:39 -0400 Subject: [PATCH 52/57] Dynamic Product (#710) This PR adds a dynamic product to SnapKit. Having a dynamic product is important in modular project structures; multiple packages may be using SnapKit, and this allows that support without the end-user have to wrap SnapKit in their own package that exposes it and using that package in lieu of SnapKit. --- Package.swift | 1 + 1 file changed, 1 insertion(+) diff --git a/Package.swift b/Package.swift index 7320cd8..c3d31cd 100644 --- a/Package.swift +++ b/Package.swift @@ -34,6 +34,7 @@ let package = Package( ], products: [ .library(name: "SnapKit", targets: ["SnapKit"]), + .library(name: "SnapKit-Dynamic", type: .dynamic, targets: ["SnapKit"]), ], targets: [ .target(name: "SnapKit", path: "Sources"), From 9d0adadafce49c67afd51af776169a8b26c9705a Mon Sep 17 00:00:00 2001 From: "Mr. Ming" Date: Fri, 14 May 2021 11:41:39 +0800 Subject: [PATCH 53/57] Fix warning about `class` (#714) --- Sources/LayoutConstraintItem.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/LayoutConstraintItem.swift b/Sources/LayoutConstraintItem.swift index a59de6b..9b61d18 100644 --- a/Sources/LayoutConstraintItem.swift +++ b/Sources/LayoutConstraintItem.swift @@ -28,7 +28,7 @@ #endif -public protocol LayoutConstraintItem: class { +public protocol LayoutConstraintItem: AnyObject { } @available(iOS 9.0, OSX 10.11, *) From 80cc5696a4862be87b49bdda83b3e6514b10fb16 Mon Sep 17 00:00:00 2001 From: Teameh Date: Fri, 14 May 2021 05:42:27 +0200 Subject: [PATCH 54/57] Added Example-iOS.xcdodeproj and fixed examples (#707) --- Example-iOS/AppDelegate.swift | 4 +- .../AccentColor.colorset/Contents.json | 11 + .../AppIcon.appiconset/Contents.json | 45 ++- Example-iOS/Assets.xcassets/Contents.json | 6 + .../Example-iOS.xcodeproj/project.pbxproj | 360 ++++++++++++++++++ Example-iOS/ListViewController.swift | 4 +- 6 files changed, 411 insertions(+), 19 deletions(-) create mode 100644 Example-iOS/Assets.xcassets/AccentColor.colorset/Contents.json create mode 100644 Example-iOS/Assets.xcassets/Contents.json create mode 100644 Example-iOS/Example-iOS.xcodeproj/project.pbxproj diff --git a/Example-iOS/AppDelegate.swift b/Example-iOS/AppDelegate.swift index 9f89af6..cb672ba 100644 --- a/Example-iOS/AppDelegate.swift +++ b/Example-iOS/AppDelegate.swift @@ -13,7 +13,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 { self.window = UIWindow(frame: UIScreen.main.bounds) @@ -27,4 +27,4 @@ class AppDelegate: UIResponder, UIApplicationDelegate { return true } -} \ No newline at end of file +} diff --git a/Example-iOS/Assets.xcassets/AccentColor.colorset/Contents.json b/Example-iOS/Assets.xcassets/AccentColor.colorset/Contents.json new file mode 100644 index 0000000..eb87897 --- /dev/null +++ b/Example-iOS/Assets.xcassets/AccentColor.colorset/Contents.json @@ -0,0 +1,11 @@ +{ + "colors" : [ + { + "idiom" : "universal" + } + ], + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Example-iOS/Assets.xcassets/AppIcon.appiconset/Contents.json b/Example-iOS/Assets.xcassets/AppIcon.appiconset/Contents.json index 118c98f..8121323 100644 --- a/Example-iOS/Assets.xcassets/AppIcon.appiconset/Contents.json +++ b/Example-iOS/Assets.xcassets/AppIcon.appiconset/Contents.json @@ -2,37 +2,52 @@ "images" : [ { "idiom" : "iphone", - "size" : "29x29", - "scale" : "2x" + "scale" : "2x", + "size" : "20x20" }, { "idiom" : "iphone", - "size" : "29x29", - "scale" : "3x" + "scale" : "3x", + "size" : "20x20" }, { "idiom" : "iphone", - "size" : "40x40", - "scale" : "2x" + "scale" : "2x", + "size" : "29x29" }, { "idiom" : "iphone", - "size" : "40x40", - "scale" : "3x" + "scale" : "3x", + "size" : "29x29" }, { "idiom" : "iphone", - "size" : "60x60", - "scale" : "2x" + "scale" : "2x", + "size" : "40x40" }, { "idiom" : "iphone", - "size" : "60x60", - "scale" : "3x" + "scale" : "3x", + "size" : "40x40" + }, + { + "idiom" : "iphone", + "scale" : "2x", + "size" : "60x60" + }, + { + "idiom" : "iphone", + "scale" : "3x", + "size" : "60x60" + }, + { + "idiom" : "ios-marketing", + "scale" : "1x", + "size" : "1024x1024" } ], "info" : { - "version" : 1, - "author" : "xcode" + "author" : "xcode", + "version" : 1 } -} \ No newline at end of file +} diff --git a/Example-iOS/Assets.xcassets/Contents.json b/Example-iOS/Assets.xcassets/Contents.json new file mode 100644 index 0000000..73c0059 --- /dev/null +++ b/Example-iOS/Assets.xcassets/Contents.json @@ -0,0 +1,6 @@ +{ + "info" : { + "author" : "xcode", + "version" : 1 + } +} diff --git a/Example-iOS/Example-iOS.xcodeproj/project.pbxproj b/Example-iOS/Example-iOS.xcodeproj/project.pbxproj new file mode 100644 index 0000000..61738e0 --- /dev/null +++ b/Example-iOS/Example-iOS.xcodeproj/project.pbxproj @@ -0,0 +1,360 @@ +// !$*UTF8*$! +{ + archiveVersion = 1; + classes = { + }; + objectVersion = 52; + objects = { + +/* Begin PBXBuildFile section */ + 440B451E25D8696C00334F54 /* ListViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 440B451B25D8696C00334F54 /* ListViewController.swift */; }; + 440B452125D869A700334F54 /* BasicUIScrollViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 440B451F25D869A700334F54 /* BasicUIScrollViewController.swift */; }; + 440B452225D869A700334F54 /* SimpleLayoutViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 440B452025D869A700334F54 /* SimpleLayoutViewController.swift */; }; + 440B452B25D86C0100334F54 /* SnapKit in Frameworks */ = {isa = PBXBuildFile; productRef = 440B452A25D86C0100334F54 /* SnapKit */; }; + 44477D7225D86845009F5E40 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 44477D7125D86845009F5E40 /* AppDelegate.swift */; }; + 44477D7B25D86846009F5E40 /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 44477D7A25D86846009F5E40 /* Assets.xcassets */; }; + 44477D7E25D86846009F5E40 /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 44477D7C25D86846009F5E40 /* LaunchScreen.storyboard */; }; +/* End PBXBuildFile section */ + +/* Begin PBXFileReference section */ + 440B451B25D8696C00334F54 /* ListViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ListViewController.swift; sourceTree = ""; }; + 440B451F25D869A700334F54 /* BasicUIScrollViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = BasicUIScrollViewController.swift; path = demos/BasicUIScrollViewController.swift; sourceTree = ""; }; + 440B452025D869A700334F54 /* SimpleLayoutViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = SimpleLayoutViewController.swift; path = demos/SimpleLayoutViewController.swift; sourceTree = ""; }; + 440B452925D86BF200334F54 /* SnapKit */ = {isa = PBXFileReference; lastKnownFileType = folder; name = SnapKit; path = ..; sourceTree = ""; }; + 44477D6E25D86845009F5E40 /* Example-iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "Example-iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; }; + 44477D7125D86845009F5E40 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; }; + 44477D7A25D86846009F5E40 /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = ""; }; + 44477D7D25D86846009F5E40 /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = ""; }; + 44477D7F25D86846009F5E40 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; }; +/* End PBXFileReference section */ + +/* Begin PBXFrameworksBuildPhase section */ + 44477D6B25D86845009F5E40 /* Frameworks */ = { + isa = PBXFrameworksBuildPhase; + buildActionMask = 2147483647; + files = ( + 440B452B25D86C0100334F54 /* SnapKit in Frameworks */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXFrameworksBuildPhase section */ + +/* Begin PBXGroup section */ + 440B452725D86BDF00334F54 /* Frameworks */ = { + isa = PBXGroup; + children = ( + 440B452925D86BF200334F54 /* SnapKit */, + ); + name = Frameworks; + sourceTree = ""; + }; + 44477D6525D86845009F5E40 = { + isa = PBXGroup; + children = ( + 44477D7025D86845009F5E40 /* Example-iOS */, + 44477D6F25D86845009F5E40 /* Products */, + 440B452725D86BDF00334F54 /* Frameworks */, + ); + sourceTree = ""; + }; + 44477D6F25D86845009F5E40 /* Products */ = { + isa = PBXGroup; + children = ( + 44477D6E25D86845009F5E40 /* Example-iOS.app */, + ); + name = Products; + sourceTree = ""; + }; + 44477D7025D86845009F5E40 /* Example-iOS */ = { + isa = PBXGroup; + children = ( + 44477D7C25D86846009F5E40 /* LaunchScreen.storyboard */, + 44477D7A25D86846009F5E40 /* Assets.xcassets */, + 44477D7F25D86846009F5E40 /* Info.plist */, + 44477D7125D86845009F5E40 /* AppDelegate.swift */, + 440B451B25D8696C00334F54 /* ListViewController.swift */, + 440B451F25D869A700334F54 /* BasicUIScrollViewController.swift */, + 440B452025D869A700334F54 /* SimpleLayoutViewController.swift */, + ); + name = "Example-iOS"; + sourceTree = ""; + }; +/* End PBXGroup section */ + +/* Begin PBXNativeTarget section */ + 44477D6D25D86845009F5E40 /* Example-iOS */ = { + isa = PBXNativeTarget; + buildConfigurationList = 44477D8225D86846009F5E40 /* Build configuration list for PBXNativeTarget "Example-iOS" */; + buildPhases = ( + 44477D6A25D86845009F5E40 /* Sources */, + 44477D6B25D86845009F5E40 /* Frameworks */, + 44477D6C25D86845009F5E40 /* Resources */, + ); + buildRules = ( + ); + dependencies = ( + ); + name = "Example-iOS"; + packageProductDependencies = ( + 440B452A25D86C0100334F54 /* SnapKit */, + ); + productName = "Example-iOS"; + productReference = 44477D6E25D86845009F5E40 /* Example-iOS.app */; + productType = "com.apple.product-type.application"; + }; +/* End PBXNativeTarget section */ + +/* Begin PBXProject section */ + 44477D6625D86845009F5E40 /* Project object */ = { + isa = PBXProject; + attributes = { + LastSwiftUpdateCheck = 1250; + LastUpgradeCheck = 1250; + TargetAttributes = { + 44477D6D25D86845009F5E40 = { + CreatedOnToolsVersion = 12.5; + }; + }; + }; + buildConfigurationList = 44477D6925D86845009F5E40 /* Build configuration list for PBXProject "Example-iOS" */; + compatibilityVersion = "Xcode 9.3"; + developmentRegion = en; + hasScannedForEncodings = 0; + knownRegions = ( + en, + Base, + ); + mainGroup = 44477D6525D86845009F5E40; + productRefGroup = 44477D6F25D86845009F5E40 /* Products */; + projectDirPath = ""; + projectRoot = ""; + targets = ( + 44477D6D25D86845009F5E40 /* Example-iOS */, + ); + }; +/* End PBXProject section */ + +/* Begin PBXResourcesBuildPhase section */ + 44477D6C25D86845009F5E40 /* Resources */ = { + isa = PBXResourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 44477D7E25D86846009F5E40 /* LaunchScreen.storyboard in Resources */, + 44477D7B25D86846009F5E40 /* Assets.xcassets in Resources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXResourcesBuildPhase section */ + +/* Begin PBXSourcesBuildPhase section */ + 44477D6A25D86845009F5E40 /* Sources */ = { + isa = PBXSourcesBuildPhase; + buildActionMask = 2147483647; + files = ( + 440B452225D869A700334F54 /* SimpleLayoutViewController.swift in Sources */, + 440B451E25D8696C00334F54 /* ListViewController.swift in Sources */, + 440B452125D869A700334F54 /* BasicUIScrollViewController.swift in Sources */, + 44477D7225D86845009F5E40 /* AppDelegate.swift in Sources */, + ); + runOnlyForDeploymentPostprocessing = 0; + }; +/* End PBXSourcesBuildPhase section */ + +/* Begin PBXVariantGroup section */ + 44477D7C25D86846009F5E40 /* LaunchScreen.storyboard */ = { + isa = PBXVariantGroup; + children = ( + 44477D7D25D86846009F5E40 /* Base */, + ); + name = LaunchScreen.storyboard; + sourceTree = ""; + }; +/* End PBXVariantGroup section */ + +/* Begin XCBuildConfiguration section */ + 44477D8025D86846009F5E40 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = 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_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = dwarf; + ENABLE_STRICT_OBJC_MSGSEND = YES; + ENABLE_TESTABILITY = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_DYNAMIC_NO_PIC = NO; + GCC_NO_COMMON_BLOCKS = YES; + GCC_OPTIMIZATION_LEVEL = 0; + GCC_PREPROCESSOR_DEFINITIONS = ( + "DEBUG=1", + "$(inherited)", + ); + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 14.5; + MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE; + MTL_FAST_MATH = YES; + ONLY_ACTIVE_ARCH = YES; + SDKROOT = iphoneos; + SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG; + SWIFT_OPTIMIZATION_LEVEL = "-Onone"; + }; + name = Debug; + }; + 44477D8125D86846009F5E40 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ALWAYS_SEARCH_USER_PATHS = NO; + CLANG_ANALYZER_NONNULL = YES; + CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE; + CLANG_CXX_LANGUAGE_STANDARD = "gnu++14"; + CLANG_CXX_LIBRARY = "libc++"; + CLANG_ENABLE_MODULES = YES; + CLANG_ENABLE_OBJC_ARC = YES; + CLANG_ENABLE_OBJC_WEAK = 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_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES; + CLANG_WARN_RANGE_LOOP_ANALYSIS = YES; + CLANG_WARN_STRICT_PROTOTYPES = YES; + CLANG_WARN_SUSPICIOUS_MOVE = YES; + CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE; + CLANG_WARN_UNREACHABLE_CODE = YES; + CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; + COPY_PHASE_STRIP = NO; + DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; + ENABLE_NS_ASSERTIONS = NO; + ENABLE_STRICT_OBJC_MSGSEND = YES; + GCC_C_LANGUAGE_STANDARD = gnu11; + GCC_NO_COMMON_BLOCKS = YES; + GCC_WARN_64_TO_32_BIT_CONVERSION = YES; + GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR; + GCC_WARN_UNDECLARED_SELECTOR = YES; + GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; + GCC_WARN_UNUSED_FUNCTION = YES; + GCC_WARN_UNUSED_VARIABLE = YES; + IPHONEOS_DEPLOYMENT_TARGET = 14.5; + MTL_ENABLE_DEBUG_INFO = NO; + MTL_FAST_MATH = YES; + SDKROOT = iphoneos; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; + VALIDATE_PRODUCT = YES; + }; + name = Release; + }; + 44477D8325D86846009F5E40 /* Debug */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + INFOPLIST_FILE = Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.Example-iOS"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Debug; + }; + 44477D8425D86846009F5E40 /* Release */ = { + isa = XCBuildConfiguration; + buildSettings = { + ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; + ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor; + CODE_SIGN_STYLE = Automatic; + INFOPLIST_FILE = Info.plist; + IPHONEOS_DEPLOYMENT_TARGET = 11.0; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); + PRODUCT_BUNDLE_IDENTIFIER = "io.snapkit.Example-iOS"; + PRODUCT_NAME = "$(TARGET_NAME)"; + SWIFT_VERSION = 5.0; + TARGETED_DEVICE_FAMILY = "1,2"; + }; + name = Release; + }; +/* End XCBuildConfiguration section */ + +/* Begin XCConfigurationList section */ + 44477D6925D86845009F5E40 /* Build configuration list for PBXProject "Example-iOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 44477D8025D86846009F5E40 /* Debug */, + 44477D8125D86846009F5E40 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; + 44477D8225D86846009F5E40 /* Build configuration list for PBXNativeTarget "Example-iOS" */ = { + isa = XCConfigurationList; + buildConfigurations = ( + 44477D8325D86846009F5E40 /* Debug */, + 44477D8425D86846009F5E40 /* Release */, + ); + defaultConfigurationIsVisible = 0; + defaultConfigurationName = Release; + }; +/* End XCConfigurationList section */ + +/* Begin XCSwiftPackageProductDependency section */ + 440B452A25D86C0100334F54 /* SnapKit */ = { + isa = XCSwiftPackageProductDependency; + productName = SnapKit; + }; +/* End XCSwiftPackageProductDependency section */ + }; + rootObject = 44477D6625D86845009F5E40 /* Project object */; +} diff --git a/Example-iOS/ListViewController.swift b/Example-iOS/ListViewController.swift index 5b5082b..9a8aa96 100644 --- a/Example-iOS/ListViewController.swift +++ b/Example-iOS/ListViewController.swift @@ -39,8 +39,8 @@ class ListViewController: UITableViewController { let viewController = SimpleLayoutViewController() navigationController?.pushViewController(viewController, animated: true) } else if indexPath.row == 1 { - let viewController = ViewController() + let viewController = BasicUIScrollViewController() navigationController?.pushViewController(viewController, animated: true) } } -} \ No newline at end of file +} From 3c4900af1a9d24210760339fd24e5f1478aa3672 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Josip=20Rezi=C4=87?= Date: Wed, 15 Sep 2021 02:53:13 +0200 Subject: [PATCH 55/57] Update README.md, add missing Migration Guides section (#721) --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 8b19bd4..6b3164a 100644 --- a/README.md +++ b/README.md @@ -26,6 +26,10 @@ SnapKit is a DSL to make Auto Layout easy on both iOS and OS X. - Xcode 10.0+ - Swift 4.0+ +## Migration Guides + +- [SnapKit 3.0 Migration Guide](Documentation/SnapKit%203.0%20Migration%20Guide.md) + ## Communication - If you **need help**, use [Stack Overflow](http://stackoverflow.com/questions/tagged/snapkit). (Tag 'snapkit') From 466db39ee4ef32b0f7c8cd9f009aaf42f80beace Mon Sep 17 00:00:00 2001 From: Rhett Tuan Date: Wed, 15 Sep 2021 08:54:35 +0800 Subject: [PATCH 56/57] Make ConstraintMaker.item public (#693) --- Sources/ConstraintMaker.swift | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Sources/ConstraintMaker.swift b/Sources/ConstraintMaker.swift index 7e48b69..50d7402 100644 --- a/Sources/ConstraintMaker.swift +++ b/Sources/ConstraintMaker.swift @@ -163,7 +163,7 @@ public class ConstraintMaker { return self.makeExtendableWithAttributes(.centerWithinMargins) } - private let item: LayoutConstraintItem + public let item: LayoutConstraintItem private var descriptions = [ConstraintDescription]() internal init(item: LayoutConstraintItem) { From eb07a3adf535ec6e87d450453471f69c053a48f1 Mon Sep 17 00:00:00 2001 From: Damien Debin Date: Fri, 1 Apr 2022 11:39:38 +0200 Subject: [PATCH 57/57] Typo source directory in Podspec (#738) Source directory has been renamed in 18608ead653bfe1e05e3d1f6fb6d34f62cec49bd --- SnapKit.podspec | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/SnapKit.podspec b/SnapKit.podspec index a3e868c..a5f59ba 100644 --- a/SnapKit.podspec +++ b/SnapKit.podspec @@ -12,7 +12,7 @@ Pod::Spec.new do |s| s.osx.deployment_target = '10.11' s.tvos.deployment_target = '10.0' - s.source_files = 'Source/*.swift' + s.source_files = 'Sources/*.swift' s.swift_version = '5.0' end